#include once "windows.bi" 'in
#define UNICODE 'this
#include once "disphelper/disphelper.bi" 'order
'
Function checkProcName(processName As String) As Boolean
dim as HRESULT hres
dim as zstring ptr procID,procPath, procName
DISPATCH_OBJ(wmiSvc)
DISPATCH_OBJ(colProc)
dhInitialize(TRUE)
hres=dhGetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2",NULL,@wmiSvc)
hres=dhGetValue("%o",@colProc,wmiSvc,".ExecQuery(%s)","Select * from Win32_Process Where Name='" & processName & "'") ' where Name=\'" & "notepad.exe" & "\'")
'
Dim count As Integer
count = 0
FOR_EACH0(objProc,colProc,NULL)
count = count +1
*procPath=""
hres=dhGetValue("%s",@procPath,objProc,".ExecutablePath")
hres=dhGetValue("%s",@procID,objProc,".ProcessID")
hres=dhGetValue("%s",@procName,objProc,".Name")
'
if hres=0 then
print *procID; tab(8);*procName
end if
'
NEXT_(objProc)
Print count
SAFE_RELEASE(wmiSvc)
SAFE_RELEASE(colProc)
dhUninitialize(TRUE)
If count = 0 Then
Return FALSE
Else
Return TRUE
EndIf
End Function
Dim test As Boolean
test= checkProcName("notepad.exe")
print:print "Sleeping to Exit.." & test
Sleep
No comments:
Post a Comment