Get DLL path at runtime

前端 未结 10 1379
梦谈多话
梦谈多话 2020-11-28 22:31

I want to get a dll\'s directory (or file) path from within its code. (not the program\'s .exe file path)

I\'ve tried a few methods I\'ve found:

10条回答
  •  时光取名叫无心
    2020-11-28 23:15

    EXTERN_C IMAGE_DOS_HEADER __ImageBase;
    

    ....

    TCHAR   DllPath[MAX_PATH] = {0};
    GetModuleFileName((HINSTANCE)&__ImageBase, DllPath, _countof(DllPath));
    

提交回复
热议问题