获取进程中指定模块的文件路径
#include <windows.h>
void GetExeModulePath(char* lpszExePath, int iPathLen)
{
ZeroMemory(lpszExePath, iPathLen);
GetModuleFileNameA(NULL, lpszExePath, iPathLen);
char *lpszSlitter = strrchr(lpszExePath, '\\');
*(++lpszSlitter) = '\0';
}
#include <windows.h>
void GetDllModulePath(const char *lpszDllName, char* lpszDllPath, int iPathLen)
{
ZeroMemory(lpszDllPath, iPathLen);
HMODULE hDllModule = LoadLibraryA(lpszDllName);
if (hDllModule != INVALID_HANDLE_VALUE)
{
GetModuleFileNameA(hDllModule, lpszDllPath, iPathLen);
char *lpszSlitter = strrchr(lpszDllPath, '\\');
*(++lpszSlitter) = '\0';
}
}