其实,我是想实现判断一个应用程序是否正在运行(前提是不能通过标题判断)
网上可以查到可以通过判断PID的方法,但是我却不能取得自己的PID
请大家帮忙!!!
------解决方案--------------------
function uint getmodulehandle(string szmoudlename)library "krnl386.exe"
function uint getmoduleusage(uinthend) library "krnl386.exe"
如检查已经运行的word是否存在的代码如下;
uin t uimodule
integer nusage
uimodule=getmodulehandle("winword.exe")
nusage=getmoduleusage(uimodule)
if nusage=0 then
run(winword.exe")
end if
利用handle()函数的可选参数可以查看同一个可执行文件的另一个pb应用程序的存在,如下:
if handle(this,true)>0 then
//already running
halt close
end if
------解决方案--------------------
Function Long GetCurrentProcessId() Library "kernel32.dll"
取自己的PID
ulong ll_pid = GetCurrentProcessId()