已经知道了某个程序的HWnd了,怎样知道这个程序的全程路径和应用程序名我知道有一个DWORD GetModuleFileName(
HMODULE hModule, // handle to module to find filename for
LPTSTR lpFilename, // pointer to buffer to receive module path
DWORD nSize // size of buffer, in characters
);
但是我只知道这个应用程序的hModule~怎么办?
HMODULE hModule, // handle to module to find filename for
LPTSTR lpFilename, // pointer to buffer to receive module path
DWORD nSize // size of buffer, in characters
);
但是我只知道这个应用程序的hModule~怎么办?
CString GetProcessPath( DWORD idProcess )
{
CString sPath;
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
FALSE,
idProcess );
if( NULL != hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if( EnumProcessModules( hProcess, &hMod, sizeof( hMod ), &cbNeeded ) )
{
DWORD dw = GetModuleFileNameEx( hProcess, hMod, sPath.GetBuffer( MAX_PATH ), MAX_PATH );
sPath.ReleaseBuffer();
}
CloseHandle( hProcess );
} return( sPath );
}
可是我只知道HWND呀。
但是需要在你的stdafx.h文件的最开始添加
#define WINVER 0x0500
才能正确的进行连接