c++里如何根据应用程序名来找到这个进程的路径
1个回答
展开全部
仅供参考:
#include <windows.h>
#include <Psapi.h>
#include <iostream>
#include <string>
using namespace std;
string GetProcessFilePath(DWORD process_id)
{
HANDLE process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, process_id);
if (process == NULL)
return string();
char file_path[MAX_PATH] = { 0 };
GetModuleFileNameEx(process, NULL, file_path, MAX_PATH);
CloseHandle(process);
return string(file_path);
}
void main()
{
DWORD process_id = 0;
cout << "请输入进程ID:";
cin >> process_id;
cout << GetProcessFilePath(process_id) << endl;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询