Linia:=sTitle+' '+sClass+' '+IntToHex(wHandle,4) Add windows in the uses clause.Īdd the following function below implementation and line:įunction EnumWindowsProc(WHandle: HWND LParM: LParam): LongBool StdCall Export Project->New Project->Application->OK.Īdd a TListbox and a TButton in the form. It is up to you.Ĭreate a new Application Project. You can identify if some specific software is running or do some magic tricks with Windows API. With this simple little code you can list the windows/software that are running. Check if an EXE file is running function exe_is_running (const exename:string): Boolean EXEName: Do not extend the EXE main file name Var Hcurrentwindow:hwnd SZTEXT:ARRAY of Char Begin Result: = False Hcurrentwindow:=getwindow (Application.handle,gw_hwndfirst) While Hcurrentwindow 0 does begin if GetWindowText (Hcurrentwindow, 255) >0 then BEGIN If lowercase (pchar =lowercase (exename) THEN BEGIN Result: = true Exit End End Hcurrentwindow:=getwindow (Hcurrentwindow,gw_hwndnext) End End Method: If we want to determine if the ' Live.exe ' program is running/has started if exe_is_running (Live) then. Program Onlyrunone uses forms,windows,sysutils, Dialogs, Unit1 in ' Unit1.pas ' var Hmutex:hwnd Ret:integer Begin Application.initialize Atitle: = ' liveauction ' Application.title: = ' liveauction ' Hmutex:=createmutex (Nil,false,pchar (atitle)) Establish mutually exclusive object, the name is atitle-' liveauction ' ret:=getlasterror If reterror_already_exists THEN BEGIN//Do what we normally should do end else ReleaseMutex (Hmutex) Prevents the creation of multiple program instances Application.Run End.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |