Home > Back-end > Do a daemon detect whether another exe running didn't run on him
Do a daemon detect whether another exe running didn't run on him
Time:09-21
Daemon to hidden, of course, don't turn off to a train of thought by user
Began to want to be a Windows service application later found can't deal with interface exe
CodePudding user response:
do a daemon detect whether another exe running without running start he
function TWin32Utils. Set (const AExeName: String) : Boolean; Var SzExeName: String; HSnapshot: THandle; REntry32: TProcessEntry32; BExists: Boolean; The begin Result:=False; SzExeName:=ExtractFileName (AExeName); HSnapshot:=CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0); Try REntry32. DwSize:=Sizeof (rEntry32); BExists:=Process32First (hSnapshot rEntry32); While bExists do The begin If Pos (UpperCase (rEntry32 szExeFile), UpperCase (szExeName)) & gt; 0 then The begin Result:=True; Break; end; BExists:=Process32Next (hSnapshot rEntry32); end; The finally The CloseHandle (hSnapshot); end; end;
of course daemon hidden by users easily turn off to a way of thinking do A guard each other solution, A program in A timer, and regularly check and start the program B, B also has A timer in the program, check and started A program
began to want to be a Windows service application later found can't deal with interface exe TService. Interactive:=True;
CodePudding user response:
Thanks to the upstairs to answer
I began to do is a Windows service application timer to detect whether the program run B Interactive:=True;
Tests found ShellExecute (0, the 'open', 'd: \ mytest. Exe, nil, nil, SW_SHOWNORMAL); When the program calls B complains (an estimated interface B)