是使用G++?
我正在尝试使用G ++将项目编译为DLL。我能够成功地编译.dll并将其导入我的C#项目。 However, I am using this tutorial: http://www.richelbilderbeek.nl/CppGppCreateDll.htm说您需要在为了创建DLL。
unitEntrypoint.cpp
//---------------------------------------------------------------------------
#include <windows.h>
//---------------------------------------------------------------------------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
return 0;
}
//---------------------------------------------------------------------------
当我编译此文件外,除其他.cpp文件外,它确实可以。但是,当我排除此文件并且在任何地方都没有dllentrypoint或Winmain时,DLL也可以工作。我确实有要用“ #define dllexport __declspec(dllexport)”和“ extern” c“ C”导出的功能。
谁能告诉我 /为什么需要Winmain / dllentrypoint?
I am trying to compile a project into a dll using g++. I am able to compile the .dll and import it into my c# projects successfully. However, I am using this tutorial: http://www.richelbilderbeek.nl/CppGppCreateDll.htm which says you need to include a file such as the following in order to create a dll.
UnitEntryPoint.cpp
//---------------------------------------------------------------------------
#include <windows.h>
//---------------------------------------------------------------------------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
return 0;
}
//---------------------------------------------------------------------------
When I compile this file in addition to the other .cpp files, it does work. However, the dll also works when I exclude this file and have no DllEntryPoint or WinMain anywhere. I do have the functions I want to export wrapped with "#define DllExport __declspec( dllexport )" and extern "C".
Can anyone tell me if / why a WinMain/DllEntryPoint is required?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
dllentrypoint()函数可以说出DLL,就像在DLL注入/加载过程中所要求的第一件事一样。
DllEntryPoint() is optional and provides a entry point/main function so to speak for the dll as in it's the first thing that is called upon during dll injection/loading.