代码如下:
CHAR szPathOfComDll[MAX_PATH] = {0};
CStringA sPathOfDecode = "dllLpDecode.dll";
DWORD ret = GetModuleFileNameA(_AtlBaseModule.m_hInst, szPathOfComDll, MAX_PATH);
if (ret != 0) {
CStringA s = szPathOfComDll;
int iPos = s.ReverseFind('\\');
sPathOfDecode = s.Left(iPos + 1) + sPathOfDecode;
}
如果GetModuleFileNameA函数的第一个参数填写NULL,一般找到的是EXE进程的路径。