c++ 获取当前程序的主模块句柄
char text[2014];
GetModuleBaseNameA(GetCurrentProcess(), 0, text, 1024);
HMODULE hModule = GetModuleHandleA(text);
HMODULE hModule = GetModuleHandleA(NULL);
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, GetCurrentProcessId());
if (hSnap != INVALID_HANDLE_VALUE)
{
MODULEENTRY32 me;
me.dwSize = sizeof(me);
if (Module32First(hSnap, &me))
{
printf("%ls: %x\n", me.szModule, me.hModule);
}
}
CloseHandle(hSnap);