The Code copied from the monopoly has helped me a lot ~

Source: Internet
Author: User
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 ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.