in reply to Check the exe is running or not

One reason for wanting that is when replacing an exe file in an upgrade system - on Windows an exe becomes part of the paging system when running and cannot be replaced.

A problem though is that you can get a race condition: you check that no one is running the exe, then someone does run it milliseconds after you checked.

One neat trick you can do is to rename the exe file, even though it is running (myprog.exe.old, for example). Then you don't necessarily care if it was running, the new one will be picked up later.

Be careful when replacing DLLs though, programs can pick these up on the fly and if they get some from the old version and some from the new then all hell breaks loose.