从dll中获取DLL的名称 [英] Getting the name of a DLL from within the dll
本文介绍了从dll中获取DLL的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个dll叫foo.dll,最终用户将其重命名为bar.dll和LoadLibrary的它,我怎么能从我的dll中的名称bar.dll?
If I have a dll called "foo.dll" and the end user renames it to "bar.dll" and LoadLibrary's it, how can I get the name "bar.dll" from inside my dll?
是GetModuleFilename(hModule,buffer); ?
Is it GetModuleFilename(hModule, buffer); ?
推荐答案
是的,您需要将hModule存储在 DllMain
yes, you need to store hModule in DllMain
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
hModule = hinstDLL;
break;
}
}
这篇关于从dll中获取DLL的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文