void ShowCallerModuleName(void* calleraddr )
{
HMODULE hCallerModule = NULL;
TCHAR szModuleName[MAX_PATH] = _T("");
void *callerAddress = calleraddr;// _ReturnAddress();
if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)callerAddress, &hCallerModule))
{
GetModuleFileName(hCallerModule, szModuleName, ARRAYSIZE(szModuleName));
MessageBox(NULL, szModuleName, _T("Who is calling me?"), MB_OK);
}
}
//调用
ShowCallerModuleName(_ReturnAddress());
写到构造函数里
时间: 2024-10-08 21:16:45