Home » Source Code » cocos2dx+socket » TG3AppDllEntry.cpp

TG3AppDllEntry.cpp ( File view )

  • By 云飞 2013-10-30
  • View(s):166
  • Download(s):5
  • Point(s): 2
			
#include "ssGlobal.h"
#include "ssTsd.h"
#include "TG3_Type.h"
#include <stdio.h>
#include "TCOM.h"
#include "ssAppMgr.h"
#include "TG3AppDllEntry.h"

#ifdef __TCOM_SUPPORT__

#ifdef __cplusplus
extern "C" {

#endif

    //实现TCOM所需要的DLL函数

    //DLL提供的获取指定CLSID的指定接口
    SS_EXPORT HRESULT TDllGetClassObject(TREFCLSID rclsid, TREFIID riid, LPVOID * ppv);

    //DLL提供的查询DLL能否被Unload
    SS_EXPORT HRESULT TDllCanUnloadNow(void);

    //DLL提供的把DLL的TCOM信息加入到注册表
    SS_EXPORT HRESULT TDllRegisterServer(void);

    //DLL提供的把DLL的TCOM信息从注册表中删除
    SS_EXPORT HRESULT TDllUnregisterServer(void);

#ifdef __cplusplus

}
#endif

#ifdef __TCOM_OUTPUT_DEBUG_INFO__
#include <stdio.h>
#endif

//TCOM实现中需要用到的函数和数据

//实例对象被引用的次数
static Int32 __TCOM_ClsidInstanceRefCount;

//ClassFactory被Locked的次数
static Int32 __TCOM_CalssFactoryLockedCount;

//做必要的初始化
static Int32 __TCOM_Init()
{

    __TCOM_ClsidInstanceRefCount = 0;
    __TCOM_CalssFactoryLockedCount = 0;
    return 0;

}

//做必要的清除工作
static Int32 __TCOM_DeInit()
{

    return 0;

}

//DLL全局使用:增加对象实例被引用次数
Int32 TCOM_AddClsidInstanceRefCount()
{

    __TCOM_ClsidInstanceRefCount++;
#ifdef __TCOM_OUTPUT_DEBUG_INFO__
    SS_printf("[TCOM_SYSTEM] TCOM_AddClsidInstanceRefCount: address: %p, value: %d.\n",
		&__TCOM_ClsidInstanceRefCount, __TCOM_ClsidInstanceRefCount);
#endif
    if(__TCOM_ClsidInstanceRefCount <= 0)
	{

        return 0;
	
}
    return __TCOM_ClsidInstanceRefCount;

}

//DLL全局使用:减少对象实例被引用次数
Int32 TCOM_DecClsidInstanceRefCount()
{

    __TCOM_ClsidInstanceRefCount--;
#ifdef __TCOM_OUTPUT_DEBUG_INFO__
    SS_printf("[TCOM_SYSTEM] TCOM_DecClsidInstanceRefCount: address: %p, value: %d.\n",
		&__TCOM_ClsidInstanceRefCount, __TCOM_ClsidInstanceRefCount);
#endif
    if(__TCOM_ClsidInstanceRefCount <= 0)
	{

        return 0;
	
}
    return __TCOM_ClsidInstanceRefCount;

}

//DLL全局使用:增加ClassFactory被Locked的次数
Int32 TCOM_AddCalssFactoryLockedCount()
{

    __TCOM_CalssFactoryLockedCount++;
#ifdef __TCOM_OUTPUT_DEBUG_INFO__
    SS_printf("[TCOM_SYSTEM] TCOM_AddCalssFactoryLockedCount: address: %p, value: %d.\n",
		&__TCOM_CalssFactoryLockedCount, __TCOM_CalssFactoryLockedCount);
#endif
    if(__TCOM_CalssFactoryLockedCount <= 0)
	{

        return 0;
	
}
    return __TCOM_CalssFactoryLockedCount;

}

//DLL全局使用:减少ClassFactory被Locked的次数
Int32 TCOM_DecCalssFactoryLockedCount()
{

    __TCOM_CalssFactoryLockedCount--;
#ifdef __TCOM_OUTPUT_DEBUG_INFO__
    SS_printf("[TCOM_SYSTEM] TCOM_DecCalssFactoryLockedCount: address: %p, value: %d.\n",
		&__TCOM_CalssFactoryLockedCount, __TCOM_CalssFactoryLockedCount);
#endif
    if(__TCOM_CalssFactoryLockedCount <= 0)
	{

        return 0;
	
}
    return __TCOM_CalssFactoryLockedCount;

}

//实现TCOM所需要的DLL函数

//DLL提供的获取指定CLSID的指定接口
SS_EXPORT HRESULT TDllGetClassObject(TREFCLSID rclsid, TREFIID riid, LPVOID * ppv)
{

    return TCOM_Srv_GetClassObject(rclsid, riid, ppv);

}

//DLL提供的查询DLL能否被Unload
SS_EXPORT HRESULT TDllCanUnloadNow(void)
{

#ifdef __TCOM_OUTPUT_DEBUG_INFO__
    SS_printf("[TCOM_SYSTEM] TDllCanUnloadNow: address1: %p, address2: %p, value1: %d, value2: %d.\n",
		&__TCOM_ClsidInstanceRefCount, &__TCOM_CalssFactoryLockedCount, __TCOM_ClsidInstanceRefCount,
		__TCOM_CalssFactoryLockedCount);
#endif
    if((__TCOM_ClsidInstanceRefCount <= 0) && (__TCOM_CalssFactoryLockedCount <= 0))
        return TCOM_S_TRUE;
    return TCOM_S_FALSE;

}

//DLL提供的把DLL的TCOM信息加入到注册表
SS_EXPORT HRESULT TDllRegisterServer(void)
{

    return TCOM_Srv_RegisterServer();

}

//DLL提供的把DLL的TCOM信息从注册表中删除
SS_EXPORT HRESULT TDllUnregisterServer(void)
{

    return  TCOM_Srv_UnregisterServer();

}

#endif  //__TCOM_SUPPORT__

#ifdef _WIN32

#ifndef SS_MAKEDLL
    #error Error!!! SS_MAKEDLL Must defined!
#endif

BOOL APIENTRY DllMain(HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{

	switch (ul_reason_for_call)
	{

	case DLL_PROCESS_ATTACH:
		//进程加载动态库进行的操作
#ifdef __TCOM_SUPPORT__
        __TCOM_Init();
#endif
		break;
	case DLL_THREAD_ATTACH:
		//线程加载动态库进行的操作
		break;
	case DLL_THREAD_DETACH:
		//线程卸载动态库进行的操作
		break;
	case DLL_PROCESS_DETACH:
		//进程卸载动态库进行的操作
#ifdef __TCOM_SUPPORT__
        __TCOM_DeInit();
#endif
		break;
	
}
	return TRUE;

}
#else   //linux

#ifndef SS_SHARED
    #error Error!!! SS_SHARED Must defined!
#endif

void __attribute((constructor)) TG3_Dll_Attach()
{

    //进程加载动态库进行的操作
#ifdef __TCOM_SUPPORT__
    __TCOM_Init();
#endif

}

void __attribute((destructor)) TG3_Dll_Detach()
{

    //进程卸载动态库进行的操作
#ifdef __TCOM_SUPPORT__
    __TCOM_DeInit();
#endif

}

#endif

//如果不是作为TG3的动态库应用,请在VC项目中和TMK3文件中定义  __TG3_PURE_DLL__ 宏
#ifndef __TG3_PURE_DLL__

//动态库应用使用的统一导出名字的入口函数
SS_EXPORT Int32 TDllTG3AppMain(const TUChar * pAppID, UInt32 nCmd, void * pCmdParam)
{

	Int32 retValue;

	//初始化TCOM
	TCoInitialize(NULL);

	retValue = TG3AppMain(pAppID, nCmd, pCmdParam);

	//释放TCOM
	TCoUninitialize();

	return retValue;

}

#endif


			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 2

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
ChatClient.cpp513.00 B14-01-12 18:00
ChatClient.vcproj4.58 kB12-01-12 15:43
ChatClient.vcproj.PCoS-20111206OT.Administrator.user1.39 kB14-01-12 18:40
ODSocket.cpp3.69 kB12-01-12 16:37
ODSocket.h1.61 kB12-01-12 13:43
ReadMe.txt1.29 kB10-01-12 16:26
stdafx.cpp297.00 B10-01-12 16:26
stdafx.h320.00 B10-01-12 16:26
targetver.h765.00 B10-01-12 16:26
ChatClient.sln896.00 B10-01-12 16:26
ChatClient.suo14.00 kB14-01-12 18:40
Android.mk880.00 B12-01-12 17:39
readme.doc170.00 kB14-01-12 18:40
HelloWorld.mkb291.00 B01-12-11 18:36
Main.cpp250.00 B01-12-11 18:36
Main.h42.00 B01-12-11 18:36
AndroidManifest.xml1.13 kB01-12-11 18:36
build_native.sh605.00 B01-12-11 18:36
default.properties364.00 B01-12-11 18:36
R.java867.00 B01-12-11 18:36
Android.mk303.00 B01-12-11 18:36
Application.mk148.00 B01-12-11 18:36
Android.mk534.00 B01-12-11 18:36
main.cpp993.00 B01-12-11 18:36
list.sh362.00 B01-12-11 18:36
icon.png7.17 kB01-12-11 18:36
icon.png2.24 kB01-12-11 18:36
icon.png4.00 kB01-12-11 18:36
game_demo.xml578.00 B01-12-11 18:36
helloworld_demo.xml595.00 B01-12-11 18:36
strings.xml112.00 B01-12-11 18:36
ApplicationDemo.java2.37 kB01-12-11 18:36
Cocos2dxAccelerometer.java3.17 kB01-12-11 18:36
Cocos2dxActivity.java7.47 kB01-12-11 18:36
Cocos2dxBitmap.java11.16 kB01-12-11 18:36
Cocos2dxGLSurfaceView.java13.50 kB01-12-11 18:36
Cocos2dxMusic.java6.06 kB01-12-11 18:36
Cocos2dxRenderer.java4.70 kB01-12-11 18:36
Cocos2dxSound.java7.63 kB01-12-11 18:36
Cocos2dxTypefaces.java1.71 kB01-12-11 18:36
.badaprj171.00 B01-12-11 18:36
.cproject77.53 kB01-12-11 18:36
.project2.91 kB01-12-11 18:36
application.xml622.00 B01-12-11 18:36
MainMenu.png15.87 kB01-12-11 18:36
Splash.png84.47 kB01-12-11 18:36
manifest.xml871.00 B01-12-11 18:36
.badaprj260.00 B01-12-11 18:36
.cproject75.58 kB01-12-11 18:36
.project3.06 kB01-12-11 18:36
application.xml866.00 B01-12-11 18:36
Splash_type2.png29.58 kB01-12-11 18:36
Splash_type3.png34.29 kB01-12-11 18:36
Splash_type4.png84.47 kB01-12-11 18:36
test_type2.png8.00 kB01-12-11 18:36
test_type3.png8.00 kB01-12-11 18:36
test_type4.png12.04 kB01-12-11 18:36
manifest.xml779.00 B01-12-11 18:36
HelloWorldEntry.cpp1.23 kB01-12-11 18:36
Android.mk760.00 B01-12-11 18:36
AppDelegate.cpp4.05 kB23-12-11 11:12
AppDelegate.h1.09 kB01-12-11 18:36
HelloWorldScene.cpp4.26 kB14-01-12 18:18
HelloWorldScene.h899.00 B07-01-12 18:56
ODSocket.cpp3.69 kB12-01-12 17:11
ODSocket.h1.63 kB12-01-12 18:58
sdBall.cpp2.14 kB10-01-12 18:09
sdBall.h571.00 B22-12-11 19:54
sdDangBan.cpp2.51 kB14-01-12 18:05
sdDangBan.h725.00 B22-12-11 19:54
AppController.h1.45 kB01-12-11 18:36
AppController.mm4.93 kB01-12-11 18:36
HelloWorld-Info.plist963.00 B01-12-11 18:36
project.pbxproj132.52 kB01-12-11 18:36
HelloWorld_Prefix.pch189.00 B01-12-11 18:36
main.m368.00 B01-12-11 18:36
RootViewController.h1.36 kB01-12-11 18:36
RootViewController.mm2.61 kB01-12-11 18:36
project.pbxproj137.45 kB01-12-11 18:36
.cproject141.13 kB01-12-11 18:36
.project2.77 kB01-12-11 18:36
main.cpp213.00 B01-12-11 18:36
main.h114.00 B01-12-11 18:36
Makefile977.00 B01-12-11 18:36
postCompiled.sh804.00 B01-12-11 18:36
app.config.txt90.00 B01-12-11 18:36
app.icf139.00 B01-12-11 18:36
background.png477.73 kB22-12-11 19:30
Ball.png3.35 kB21-12-11 14:14
CloseNormal.png5.12 kB01-12-11 18:36
CloseSelected.png6.02 kB01-12-11 18:36
DangBan.png9.23 kB21-12-11 15:15
HelloWorld.png27.88 kB21-12-11 16:38
Icon.png9.11 kB01-12-11 18:36
HelloWorld.win32.vcproj5.21 kB12-01-12 17:16
HelloWorld.win32.vcproj.PCoS-20111206OT.Administrator.user1.44 kB14-01-12 18:17
HelloWorld.win32.vcproj.user487.00 B01-12-11 18:36
HelloWorld.win32.vcxproj7.01 kB01-12-11 18:36
HelloWorld.win32.vcxproj.filters1.18 kB01-12-11 18:36
HelloWorld.win32.vcxproj.user764.00 B01-12-11 18:36
main.cpp408.00 B01-12-11 18:36
main.h277.00 B01-12-11 18:36
HelloWorld.TMK33.03 kB01-12-11 18:36
HelloWorld.wophone.vcproj6.34 kB01-12-11 18:36
HelloWorld.wophone.vcproj.user1.40 kB01-12-11 18:36
HelloWorldUnicodeScript.h250.00 B01-12-11 18:36
HelloWorldUnicodeScript_str.h604.00 B01-12-11 18:36
main.cpp389.00 B01-12-11 18:36
Makefile.ARM2.07 kB01-12-11 18:36
NewDeleteOp.cpp2.05 kB01-12-11 18:36
HelloWorld.upiproj40.80 kB01-12-11 18:36
install.xml380.00 B01-12-11 18:36
TG3AppDllEntry.cpp5.27 kB01-12-11 18:36
TG3AppDllEntry.h1.39 kB01-12-11 18:36
ODSocket.cpp3.69 kB12-01-12 16:37
ODSocket.h1.61 kB12-01-12 13:43
ReadMe.txt1.27 kB10-01-12 16:34
Server.cpp701.00 B14-01-12 18:00
Server.vcproj4.53 kB12-01-12 16:24
Server.vcproj.PCoS-20111206OT.Administrator.user1.39 kB14-01-12 18:40
stdafx.cpp293.00 B10-01-12 16:34
stdafx.h320.00 B10-01-12 16:34
targetver.h765.00 B10-01-12 16:34
Server.sln884.00 B10-01-12 16:35
Server.suo18.00 kB14-01-12 18:40
<application>0.00 B14-01-12 18:39
<application>0.00 B14-01-12 18:39
<lib>0.00 B14-01-12 18:39
<cocos2dx>0.00 B14-01-12 18:39
<cocos2dx>0.00 B14-01-12 18:39
<org>0.00 B14-01-12 18:39
<helloworld>0.00 B14-01-12 18:39
<drawable-hdpi>0.00 B14-01-12 18:39
<drawable-ldpi>0.00 B14-01-12 18:39
<drawable-mdpi>0.00 B14-01-12 18:39
<layout>0.00 B14-01-12 18:39
<values>0.00 B14-01-12 18:39
<org>0.00 B14-01-12 18:39
<Icons>0.00 B14-01-12 18:39
<Icons>0.00 B14-01-12 18:39
<gen>0.00 B14-01-12 18:39
<jni>0.00 B14-01-12 18:39
<res>0.00 B14-01-12 18:39
<src>0.00 B14-01-12 18:39
<sdk1.0>0.00 B14-01-12 18:39
<sdk2.0>0.00 B14-01-12 18:39
<src>0.00 B14-01-12 18:39
<HelloWorld.xcodeproj>0.00 B14-01-12 18:39
<HelloWorld.xcodeproj>0.00 B14-01-12 18:39
<pak>0.00 B14-01-12 18:39
<ChatClient>0.00 B14-01-12 18:41
<airplay>0.00 B14-01-12 18:39
<android>0.00 B14-01-12 18:39
<bada>0.00 B14-01-12 18:39
<Classes>0.00 B14-01-12 18:39
<ios>0.00 B14-01-12 18:39
<iphone>0.00 B14-01-12 18:39
<Linux>0.00 B14-01-12 18:39
<Resource>0.00 B14-01-12 18:39
<win32>0.00 B14-01-12 18:42
<wophone>0.00 B14-01-12 18:39
<Server>0.00 B14-01-12 18:41
<PCClient>0.00 B14-01-12 18:41
<HelloWorld>0.00 B14-01-12 18:39
<PCServer>0.00 B14-01-12 18:41
...
Sponsored links

TG3AppDllEntry.cpp (1.05 MB)

Need 2 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D