I have this windows mobile application.
I'd like to launch an updater.exe that will update my mobile app. But I need to stop my mobile app before the updater process launch .. how can I achieve this?
I have this windows mobile application.
I'd like to launch an updater.exe that will update my mobile app. But I need to stop my mobile app before the updater process launch .. how can I achieve this?
What I've done is if you're launching the update application from inside your own, execute the updater with Process.Start("\Path\To\Updater.exe");
, then immediately close the main app (with this.Close();
or Application.Quit();
. It should work just fine.
To kill the main application from inside the updater, you'll have to use p/invoke and system call methods to find and kill the main application. It should end up something like this (untested):
class CloseWindow
{
[DllImport("coredll.dll")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("coredll")]
public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
public const int WM_CLOSE = 0x0010;
public static void Close(string windowName)
{
IntPtr hWnd = FindWindow(null, windowName);
SendMessage(hWnd, WM_CLOSE, null, null);
}
}
then call it with CloseWindow.Close("My Application Title");
.