public boolean of_hasrun()
il_handle = createmutex(0, 1, is_appname)
if waitforsingleobject(il_handle, 0) > 0 then
return true //
else
return false
end if
is_appname 是应用名,随便取值。il_handle 是我作其他用的.
当然啦,你还要先声名这些APIs:
Public Function long CreateMutex(long security, long hasOwner, string Name) library "kernel32.dll" alias for "CreateMutexA;Ansi"
Public Function long WaitForSingleObject(long hHandle, long dwMilliseconds) library "kernel32.dll" Alias for WaitForSingleObject
Public Function long CloseHandle(long hHandel) library "kernel32.dll"
Public Function long GetWindow(long hHandle, long wCmd) library "user32.dll"
一起学习,帮助如下:
For applications, the Handle function does not return a useful value when the previous flag is true. You can use the FindWindow Windows function to determine whether a Windows application is already running. FindWindow returns the handle of a window with a given title.
Declare FindWindow and SetForegroundWindow as global external functions: