NX 获取运行dll文件的全名
程序员文章站
2022-06-26 08:02:42
...
//NX 获取运行dll文件的全名
HMODULE GetSelfModuleHandle()
{
MEMORY_BASIC_INFORMATION mbi;
return ((::VirtualQuery(GetSelfModuleHandle, &mbi, sizeof(mbi)) != 0) ? (HMODULE)mbi.AllocationBase : NULL);
}
extern CString GetCurrentPath(void)
{
TCHAR path[MAX_PATH] = {0};
memset(path, 0, sizeof(path));
GetModuleFileName(GetSelfModuleHandle(),path,sizeof(path));
int l = _tcslen(path);
char driveA[1024] = {0};
char drive[_MAX_DRIVE] = {0};
char dir[_MAX_DIR] = {0};
char fname[_MAX_FNAME] = {0};
char ext[_MAX_EXT] = {0};
int length = WideCharToMultiByte(CP_ACP, 0, path, -1, NULL, 0, NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, path, -1, driveA, length, NULL, NULL);
_splitpath(driveA,drive ,dir ,fname ,ext);
string str = fname;
str = str + ".dll";
return CString(str.c_str());
}