Herzlich Willkommen, lieber Gast!
  Sie befinden sich hier:

  Forum » VC++ / MFC » Programm Schließen

Forum | Hilfe | Team | Links | Impressum | > Suche < | Mitglieder | Registrieren | Einloggen
  Quicklinks: MSDN-Online || STL || clib Reference Grundlagen || Literatur || E-Books || Zubehör || > F.A.Q. < || Downloads   

Autor Thread - Seiten: > 1 <
000
08.08.2002, 08:20 Uhr
~MORA
Gast


Hallo,
wie kann ich abfragen, ob das Programm abc.exe, das ich mit folgendem Code gestartet habe:
1. Ob das Programm beendet wurde (durch den User)
2. Ob das Programm tatsächlich durch meinen Befehl beendet wurde


C++:
    // TODO: Code für Befehlsbehandlungsroutine hier einfügen
            STARTUPINFO si;
            SECURITY_ATTRIBUTES saProc;
            PROCESS_INFORMATION piProc;
            ZeroMemory(&si, sizeof(si));
            si.wShowWindow=ShowWindow(SW_SHOWNOACTIVATE);
            saProc.nLength = sizeof(saProc);
            saProc.lpSecurityDescriptor = NULL;
            saProc.bInheritHandle = FALSE;
        
            ::CreateProcess ("C:\\VVA\\ABC\\abc.exe",NULL,
            &saProc, NULL,FALSE,0,NULL,NULL,&si,&piProc);
            HANDLE hPro = piProc.hProcess;
            hProcess=hPro; }


void COABCDlg::Beenden ()
{

// hier abfrage, ob das Programm schon beendet wurde???
    //wenn noch offen, dann nächste Zeile ausführen (zum beenden)
    TerminateProcess(hProcess, 34);

//hier abfrage, ob das Programm durch TerminateProcess wirklich beendet ist ???
    //wenn beendet, dann folgende Zeilen ausführen
    m_strSourcePath="C:\\VVA\\ABC\\abc.exe";
    m_fSource.Remove(m_strSourcePath);

    DestroyWindow();  //eigene Anwendung schließen
}



Dieser Post wurde am 08.08.2002 um 10:07 Uhr von FloSoft editiert.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
001
08.08.2002, 10:06 Uhr
FloSoft
Medialer Over-Flow
(Administrator)


Hallo, das geht mit


C++:
BOOL GetExitCodeProcess(
  HANDLE hProcess,     // handle to the process
  LPDWORD lpExitCode   // termination status
);



also z.B.:


C++:

void COABCDlg::Beenden ()
{
    // hier abfrage, ob das Programm schon beendet wurde???
    DWORD dwExitCode = 0;
    GetExitCodeProcess(hProcess,&dwExitCode);
    if(dwExitCode == STILL_ACTIVE)
    {
        //wenn noch offen, dann nächste Zeile ausführen (zum beenden)
        TerminateProcess(hProcess, 34);
    }

    //hier abfrage, ob das Programm durch TerminateProcess wirklich beendet ist ???
    dwExitCode = 0;
    GetExitCodeProcess(hProcess,&dwExitCode);
    if(dwExitCode != STILL_ACTIVE)
    {
        //wenn beendet, dann folgende Zeilen ausführen
        m_strSourcePath="C:\\VVA\\ABC\\abc.exe";
        m_fSource.Remove(m_strSourcePath);
    }
    DestroyWindow(); //eigene Anwendung schließen
}



Achja, bitte benutz die CppTags
--
class God : public ChuckNorris { };

Dieser Post wurde am 08.08.2002 um 10:07 Uhr von FloSoft editiert.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
002
08.08.2002, 11:38 Uhr
~MORA
Gast


Hallo Flo,
Danke
und noch eine Frage:
wie kann ich noch ein paar Dinge erledigen, wenn Windows (z.B. durch End_Task) meine Dialog_Anwendung zwangsläufig schließen will?
So wie OnAppExit() (aber bei Dialog ist wohl nicht vorhanden)

Mit f. G.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
Seiten: > 1 <     [ VC++ / MFC ]  


ThWBoard 2.73 FloSoft-Edition
© by Paul Baecher & Felix Gonschorek (www.thwboard.de)

Anpassungen des Forums
© by Flo-Soft (www.flo-soft.de)

Sie sind Besucher: