dll工程设置


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


你可能感兴趣的:(dll工程设置)