2009-08-19 6 views
1

나는이 Windows 모바일 응용 프로그램을 가지고 있습니다.모바일 앱을 어떻게 죽입니까?

내 모바일 앱을 업데이트하는 updater.exe를 시작하고 싶습니다. 하지만 업데 이터 프로세스가 시작되기 전에 내 모바일 앱을 중지해야합니다. 어떻게해야합니까? 당신이 당신의 자신의 내부에서 업데이트 응용 프로그램을 실행하는 경우 내가 무슨 짓을했는지

답변

3

이며, 즉시 this.Close(); 또는 Application.Quit();와 (주 응용 프로그램을 닫습니다, Process.Start("\Path\To\Updater.exe");으로 업데이터를 실행합니다. 그냥 잘 작동합니다.

을 .

이 업데이트 프로그램 내부에서 기본 응용 프로그램을 죽일하려면 찾아 주 응용 프로그램을 죽일 P/호출하고 시스템 호출 방법을 사용해야합니다 그것은 (테스트되지 않은) 같은 것을 끝낼해야합니다

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); 
    } 
}

CloseWindow.Close("My Application Title");으로 전화하십시오.

+0

고마워, 정확히 내가 찾고 있던 것이었다! – pdiddy

관련 문제