能力值:
( LV2,RANK:10 )
|
-
-
2 楼
搞定了。。。
BOOL GetProcessPath(LPCSTR strProcess, LPSTR strPath, int nPathSize)
{
HANDLE hSnap = NULL;
PROCESSENTRY32 pe32 = {0};
MODULEENTRY32 me32 = {0};
BOOL bRet = TRUE;
DWORD pid = 0;
int i = 0;
int nLen = 0;
pe32.dwSize = sizeof(pe32);
me32.dwSize = sizeof(me32);
hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnap == NULL)
{
bRet = FALSE;
goto fun_end;
}
if (Process32First(hSnap, &pe32))
{
do
{
if (stricmp(strProcess, pe32.szExeFile) == 0)
{
pid = pe32.th32ProcessID;
break;
}
} while (Process32Next(hSnap, &pe32));
}
if (pid == 0)
{
bRet = FALSE;
goto fun_end;
}
CloseHandle(hSnap);
hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);
if (hSnap == NULL)
{
bRet = FALSE;
goto fun_end;
}
if (!Module32First(hSnap, &me32))
{
bRet = FALSE;
goto fun_end;
}
ZeroMemory(strPath, nPathSize);
strcpy(strPath, me32.szExePath);
nLen = strlen(strPath);
for (i = nLen; i > 0; i--)
{
if (strPath[i] == '\\')
{
break;
}
strPath[i] = 0;
}
fun_end:
if (hSnap)
{
CloseHandle(hSnap);
}
return bRet;
}
|
能力值:
( LV2,RANK:10 )
|
-
-
3 楼
假如要获得该进程打开的文件的路径 怎么弄 比如 WINWORD.EXE中打开的word的路径?
|
能力值:
( LV2,RANK:10 )
|
-
-
4 楼
wmic process where name="WINWORD.EXE" get commandline
|
|
|