The software update module must determine when overwriting files. Program Whether it is running or not. I thought about using findwindow, but the effect was not very good. I found the following information to see this Code Yes, it has already been added to the program and almost achieved that goal. (first, let's see if the program is running. If it is run, kill the running program process ), I didn't finish the test yesterday because of the time. I believe I can test it for them today .. Uses tlhelp32;
// Processname: the name of the program or process (note that the path is not included); Return Value: whether the program is running.
Function processrun ( Const Processname: String ): Boolean;
VaR
Hprocess: longword;
Pinfo: tprocessentry32;
Begin
Hprocess: = Createconlhelp32snapshot (th32cs_snapprocess, 0 );
Pinfo. dwsize: = Sizeof (tprocessentry32 );
Result: = Process32first (hprocess, pinfo );
While Result Do
Begin
If Extractfilename (pinfo. szexefile) <> Processname then
Result: = Process32next (hprocess, pinfo)
Else Break;
End;
If Not result then
// Start the program (you can write it yourself. I don't know where your program is)
Else MessageBox ( 0 , ' The program is running! ' , ' Prompt ' , Mb_iconinformation or mb_ OK );
End;
The code is Delphi, and C # is still learning ....