如何获取DLL的文件名? [英] How to get the filename of a DLL?
问题描述
我有一个C ++ Windows应用程序myapp.exe加载了几个插件。
插件需要找到他们的DLL的路径。我可以使用GetModuleFileName为此,但它需要插件DLL的句柄。我不知道在哪里得到这个句柄。
一个选项是使用GetModuleHandle(GetModuleHandle(myplugin.dll)),但这需要的名称
任何帮助都是值得赞赏的。
我不知道在哪里得到这个句柄
它作为一个参数传递给你的DLLMain()入口函数。
如果插件不能访问它的DLLMain条目函数,它可以在自己的内存块上使用VirtualQuery函数,并使用填充的MEMORY_BASIC_INFORMATION结构的AllocationBase字段作为其HMODULE。
I have a C++ Windows application myapp.exe which loads several plug-ins.
Plug-ins need to find the path to their DLLs. I can use GetModuleFileName for this, but it need the handle for the plug-in DLL. I don't know where to get this handle. GetModuleHandle(NULL) returns the handle to the executable.
One option is to use GetModuleHandle (GetModuleHandle("myplugin.dll") ) , but this requires the name of the plugin to be hardcoded which I want to avoid.
Any help is appreciated.
Paul
I don't know where to get this handle
It's passed as a parameter to your DLLMain() entry function.
If the plugin can't access its DLLMain() entry function, it can use the VirtualQuery function on a piece of its own memory and use the AllocationBase field of the filled-in MEMORY_BASIC_INFORMATION structure as its HMODULE.
这篇关于如何获取DLL的文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!