GetProcessImageFileName获取进程路径
2011-10-08 16:43
731 查看
HANDLE hProcess=OpenProcess(PROCESS_QUERY_INFORMATION,FALSE,pe.th32ProcessID); if ( GetProcessImageFileName(hProcess,szFilePath,MAX_PATH)!=0 ){ mystring strFilePath = CCommon::DosDevicePath2LogicalPath(szFilePath); }
DosDevicePath2LogicalPath代码摘自:ms-help://MS.MSDNQTR.v80.chs/MS.MSDN.v80/MS.WIN32COM.v10.en/fileio/fs/obtaining_a_file_name_from_a_file_handle.htm
mystring CCommon::DosDevicePath2LogicalPath(LPCTSTR lpszDosPath) { mystring strResult; // Translate path with device name to drive letters. TCHAR szTemp[MAX_PATH]; szTemp[0] = '\0'; if ( lpszDosPath==NULL || !GetLogicalDriveStrings(_countof(szTemp)-1, szTemp) ){ return strResult; } TCHAR szName[MAX_PATH]; TCHAR szDrive[3] = TEXT(" :"); BOOL bFound = FALSE; TCHAR* p = szTemp; do{ // Copy the drive letter to the template string *szDrive = *p; // Look up each device name if ( QueryDosDevice(szDrive, szName, _countof(szName)) ){ UINT uNameLen = (UINT)_tcslen(szName); if (uNameLen < MAX_PATH) { bFound = _tcsnicmp(lpszDosPath, szName, uNameLen) == 0; if ( bFound ){ // Reconstruct pszFilename using szTemp // Replace device path with DOS path TCHAR szTempFile[MAX_PATH]; _stprintf_s(szTempFile, TEXT("%s%s"), szDrive, lpszDosPath+uNameLen); strResult = szTempFile; } } } // Go to the next NULL character. while (*p++); } while (!bFound && *p); // end of string return strResult; }
相关文章推荐
- 通过GetProcessImageFileName函数获取进程路径
- PsGetProcessImageFileName - 获取进程的主模块路径
- 获得进程可执行文件的路径: GetModuleFileNameEx, GetProcessImageFileName, QueryFullProcessImageName
- 获得进程可执行文件的路径: GetModuleFileNameEx, GetProcessImageFileName, QueryFullProcessImageName
- 获得进程可执行文件的路径: GetModuleFileNameEx, GetProcessImageFileName, QueryFullProcessImageName
- 获得进程可执行文件的路径: GetModuleFileNameEx, GetProcessImageFileName, QueryFullProcessImageName
- GetModuleFileName获取当前进程完整路径
- GetModuleFileName获取当前进程已加载模块的文件的完整路径
- 获取当前进程目录 GetCurrentDirectory() 及 获取当前运行模块路径名GetModuleFileName()
- VC新建目录CreateDirectory、得到exe存放路径GetModuleFileName、获取当前目录GetCurrentDirectory、CFileDialog设置打开默认路径
- VC中使用GetModuleFileName获取应用程序路径 转帖
- 路径参数函数:路径的获取(GetModuleFileName)和拆分(_splitpath)
- oracle安装(win7#64安装oracle10#32)解决无法定位程序输入点GetProcessImageFileNameW于动态链接库PSAPI.DLL
- VC中使用GetModuleFileName获取应用程序路径
- 64位下GetModuleFileName获取不到进程名的原因
- 十一:VC中使用GetModuleFileName获取应用程序路径
- 获取文件的绝对路径, GetCurrentDirectory()和GetModuleFileName()函数的区别
- VC中使用GetModuleFileName获取应用程序路径 转帖
- VC中使用GetModuleFileName获取应用程序路径
- MFC获取路径的两个函数GetCurrentDirectory()和GetModuleFileName()