1.在頭文件中定義導出 (使用__declspec,一個Microsoft定義的關鍵字)
#ifdef _WIN32
#ifdef TRUCCRUNTIMESERVICE_EXPORTS
#define RUNTIMESERVICE_EXPORT __declspec(dllexport)
#else
#define RUNTIMESERVICE_EXPORT __declspec(dllimport)
#endif
#else
#define RUNTIMESERVICE_EXPORT
#endif
//注意 TRUCCRUNTIMESERVICE_EXPORTS 由vc中project setting->c++->預處理定義 中取得,不能自己在頭文件中亂定義
2.在類(函數)定義處制定導出
class RUNTIMESERVICE_EXPORT RunTimeService
{ };
3.在cpp文件中定義dll的入口函數
#ifdef _WIN32
#include <windows.h>
BOOL WINAPI DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
#endif
copy ./debug/truccruntimeservice.lib ../../lib/truccruntimeservice.lib
copy ./runtimeservice.h ../../shared/./runtimeservice.h