0

我尝试在 Borland c++ 5.02 中创建 *.dll 文件,我对这个函数有疑问

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
                     )
{
    return TRUE;
}

我尝试编译我的项目,但编译器显示错误。这个函数有什么问题,或者这个编译器与另一个编译器有不同的类型风格吗?

4

2 回答 2

1

如果你已经安装了 BC5.02 的示例,查看 BC5\EXAMPLES\WINDOWS\DLLDEMO DLL 入口点定义为:

// Every DLL has an entry point LibMain || DllEntryPoint
// and an exit point WEP.
#if defined(__FLAT__)
BOOL WINAPI DllEntryPoint( HINSTANCE hinstDll,
                           DWORD fdwRreason,
                           LPVOID plvReserved)
#else /* not flat model  */
int FAR PASCAL LibMain( HINSTANCE hInstance,
                        WORD wDataSegment,
                        WORD wHeapSize,
                        LPSTR lpszCmdLine )
#endif /* __FLAT */
于 2013-10-10T07:34:06.640 回答
1

如果是ac风格函数::

#define WINAPI __stdcall

extern "C" BOOL APIENTRY WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    return TRUE;
}

if c++ 风格函数::

BOOL APIENTRY WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    return TRUE;
}
于 2016-06-29T07:20:16.327 回答