CreateProcess unter WinXp

smathedark

Mitglied
Hallo,
ich habe grade das Problem das ich eine Software von Windows98 auf Windows XP umstellen soll. Hierbei bin ich auf einen Fehler gestoßen und zwar Funktioniert unter WinXP die Umleitung der Ausgabe einer mit CreateProcess aufgerufenen Applikation in eine Datei nichtmehr. Die Ausgabe wird zwar von der Console weggenommen (erscheint also dort nicht) gelangt aber nie in die Datei. Unter Win 98 läuft das alles super. Laut MSDN ist die Funktion aber WinXP kompatibel. Anlegen der Datei funktioniert und ich kann auch in die Datei schreiben also sollte es denke ich nicht an den Dateirechten liegen. Hier mal ein Beispielcode.
Code:
hwndOutput = CreateFile(
                     pfad,
                     GENERIC_READ|GENERIC_WRITE,
                     FILE_SHARE_READ,
                     NULL,
                     CREATE_ALWAYS,   //OPEN_ALWAYS,
                     FILE_ATTRIBUTE_ARCHIVE, 0);
    if (hwndOutput == INVALID_HANDLE_VALUE) 
    { 
        printf("Could not open file.");   // process error 
    } 
  
      STARTUPINFO_MODUL.hStdInput  = NULL;//GetStdHandle(STD_INPUT_HANDLE);
      STARTUPINFO_MODUL.hStdOutput = hwndOutput;
     //STARTUPINFO_MODUL.hStdError  = hwndOutput; 
     STARTUPINFO_MODUL.dwFlags=STARTF_USESTDHANDLES;

    // Start the child process. 
    if( !CreateProcess( NULL, // No module name (use command line). 
        "ping -n 10 100.1.1.254", // Command line. 
        NULL,             // Process handle not inheritable. 
        NULL,             // Thread handle not inheritable. 
       TRUE,            // Set handle inheritance to FALSE. 
        0,                // No creation flags. 
        NULL,             // Use parent's environment block. 
        NULL,             // Use parent's starting directory. 
        &STARTUPINFO_MODUL,              // Pointer to STARTUPINFO structure.
        &pi )             // Pointer to PROCESS_INFORMATION structure.
    ) 
    {
      printf( "CreateProcess failed." );
    }

    // Wait until child process exits.
    WaitForSingleObject( pi.hProcess, INFINITE );

    // Close process and thread handles. 
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
    CloseHandle(hwndOutput);

Kennt jemand die Problematik?

MfG
SmaTheDark
 
Zurück