add wmi proc_exe wrapper

This commit is contained in:
Doug MacEachern 2009-08-05 15:08:43 -07:00
parent 2550c6373a
commit 8c1608bb76
1 changed files with 30 additions and 0 deletions

View File

@ -192,3 +192,33 @@ extern "C" int sigar_proc_args_wmi_get(sigar_t *sigar, sigar_pid_t pid,
return status; return status;
} }
extern "C" int sigar_proc_exe_wmi_get(sigar_t *sigar, sigar_pid_t pid,
sigar_proc_exe_t *procexe)
{
int status;
TCHAR buf[MAX_PATH+1];
WMI *wmi = new WMI();
if (FAILED(wmi->Open())) {
return GetLastError();
}
procexe->name[0] = '\0';
if (FAILED(wmi->GetProcExecutablePath(pid, buf))) {
status = GetLastError();
}
else {
status = SIGAR_OK;
/* SIGAR_W2A(buf, procexe->name, sizeof(procexe->name)); */
WideCharToMultiByte(CP_ACP, 0, buf, -1,
(LPSTR)procexe->name, sizeof(procexe->name),
NULL, NULL);
}
wmi->Close();
delete wmi;
return status;
}