Check if app is already running?

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

Can anyone point me in the right direction to check if the application is
already running for a .NET CF 2.0 application?

Code for the regular .NET framework does not work because it uses
process.GetCurrentProcess.MainWindowHandle

which is not supported in the CF.



Dan
 
You need to P/Invoke CreateToolhelp32Snapshot, Process32First and
Process32Next .
you can also use OpenNetCF.org and use the OpenNETCF.Toolhelp namespace.

Hope this helps

Erwin Zwart
 
For your own process just create a named system mutex (P/Invoke CreateMutex
or use the OpenNETCF.Threading.NamedMutex). On startup, create and hold it.
If it already exists at that point, you know another instance is running.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
Back
Top