简体   繁体   English

使用rundll32运行C ++ DLL - 缺少条目

[英]Running C++ DLL with rundll32 - Missing entry

So I'm trying to use rundll to test and run my C++ written DLL , and i've followed the guidelines here and on other sites and the entry point looks like this: 所以我正在尝试使用rundll来测试和运行我的C ++编写的DLL,我已经遵循了这里和其他网站上的指南,入口点如下所示:

__declspec(dllexport)  void CALLBACK entry(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
{
    //do stuff
}

But the rundll process prompts me with an error message box saying "Error in C:\\path\\to\\DLL Missing entry: entry" 但rundll进程提示我一个错误消息框说“C:\\ path \\ to \\ DLL Missing entry:entry”中的错误

Attempted execution command: "rundll32 C:\\path\\to\\DLL, entry". 尝试执行命令:“rundll32 C:\\ path \\ to \\ DLL,entry”。

You can double-check by running Dumpbin.exe /exports on your DLL to see the actual exported name. 您可以通过在DLL上运行Dumpbin.exe / exports来仔细检查以查看实际的导出名称。 Which right now is not entry , as the error message tells you. 错误消息告诉您,现在哪一个不是 entry

You need to prefix extern "C" to the declaration to disable C++ name mangling. 您需要在声明前加上extern "C"以禁用C ++名称修改。

Good enough for a 64-bit executable, but that turns it into _entry@16 if this is a 32-bit DLL, still not quite good enough to keep rundll32 happy. 对于64位可执行文件来说已经足够好了,但是如果它是32位DLL,则将其转换为_entry@16 ,仍然不足以使rundll32保持幸福。 Use Project + Add New Item, Code node, pick the "Module-Definition File (.def)" item template. 使用Project + Add New Item,Code node,选择“Module-Definition File(.def)”项模板。 And make it look like this: 并使其如下所示:

EXPORTS
entry = entry

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM