Mengecek Aplikasi (exe) yang sedang running

langsung aja nih


lcExeName = "vfp9.exe"

* Is EXE running
? IsExeRunning(lcExeName)

* Terminate EXE if it's running
? IsExeRunning(lcExeName, .T.)

RETURN

FUNCTION IsExeRunning(tcName, tlTerminate)
LOCAL loLocator, loWMI, loProcesses, loProcess, llIsRunning
loLocator = CREATEOBJECT('WBEMScripting.SWBEMLocator')
loWMI = loLocator.ConnectServer()
loWMI.Security_.ImpersonationLevel = 3 && Impersonate

loProcesses = loWMI.ExecQuery([SELECT * FROM Win32_Process WHERE Name = '] + tcName + ['])
llIsRunning = .F.
IF loProcesses.Count > 0
FOR EACH loProcess in loProcesses
llIsRunning = .T.
IF tlTerminate
loProcess.Terminate(0)
ENDIF
ENDFOR
ENDIF
RETURN llIsRunning

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: