hi
How to prevent my program to open more than one time (Windows mobile) ?
and how I can make reset to my program (Windows mobile) ?
thank's
hi
How to prevent my program to open more than one time (Windows mobile) ?
and how I can make reset to my program (Windows mobile) ?
thank's
To prevent running multiple instances of you program you could use a named Mutex.
See this question. The same should apply to Windows Mobile.
I'm not sure what you mean by make reset to your program, but if you mean rebooting the device - you may want to take a look at the KernelIoControl function. Here's more information about how to p/invoke KernelIoControl.
[DllImport("coredll.dll")]
public static extern int KernelIoControl(int dwIoControlCode,
IntPtr lpInBuf,
int nInBufSize,
IntPtr lpOutBuf,
int nOutBufSize,
ref int lpBytesReturned);
//.. and the invocation..
int retBytes = 0;
// Reboot device
KernelIoControl(((0x101 << 16) | (15 << 2)), IntPtr.Zero, 0, IntPtr.Zero, 0, ref retBytes);
First, to check if your program is already running, create a named object on WinMain (ie. a named Mutex), if the create succeeds, then there are no other instances of your program running, if it fails because it exists, then you know that there is another instance of your program running. In that case use FindWindow (http://msdn.microsoft.com/en-us/library/aa929233.aspx) to search for the window of your application and then just bring it to the foreground via SetForegroundWindow (http://msdn.microsoft.com/en-us/library/aa923858.aspx)
hope this helps...