Andere Programme ausführen?

  • C++

  • Guybrush
  • 1237 Aufrufe 3 Antworten

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Andere Programme ausführen?

    Ich hab da ein Problem ^^

    Ich möchte mit C++ ein Programm schreiben mit dem man eben andere Programme öffnen bzw ausführen kann.

    Mal 2 bsp. wie ich das meine:

    Zum bsp. öffnet sich dann ein Fenster wo en Button "Winamp" oder so ist und wenn man draufklickt startet eben Winamp.

    Oder z.B. ein Autostart für eine CD o.ä. (also nicht der Autostart an sich, sondern eben das menu)

    Weiß jmd. wie so etwas geht?
  • Hey

    Feuerstein könntest du bittebitte noch ein kleines Beispiel machen wi z.b word geöffnet werden soll o.ä., ich hab jetzt ein paar mal probiert das zu schreiben, habs aber nicht hingekriegt...:/ wär echt nett..

    mfg saem
    [SIZE="1"]Signatur entsprach den Boardregeln und wurde nicht gelöscht.
    mfg saem[/size]
  • Nachfolgendes Programm öffnet das Notepad(nur XP):

    PHP-Quellcode

    1. #include <windows.h>
    2. #include <stdio.h>
    3. void main( VOID )
    4. {
    5. STARTUPINFO si;
    6. PROCESS_INFORMATION pi;
    7. ZeroMemory( &si, sizeof(si) );
    8. si.cb = sizeof(si);
    9. ZeroMemory( &pi, sizeof(pi) );
    10. // Start the child process.
    11. if( !CreateProcess( TEXT("c:\\WINDOWS\\NOTEPAD.exe"), // No module name (use command line).
    12. NULL, // Command line.
    13. NULL, // Process handle not inheritable.
    14. NULL, // Thread handle not inheritable.
    15. FALSE, // Set handle inheritance to FALSE.
    16. 0, // No creation flags.
    17. NULL, // Use parent's environment block.
    18. NULL, // Use parent's starting directory.
    19. &si, // Pointer to STARTUPINFO structure.
    20. &pi ) // Pointer to PROCESS_INFORMATION structure.
    21. )
    22. {
    23. printf( "CreateProcess failed (%d).\n", GetLastError() );
    24. return;
    25. }
    26. // Wait until child process exits.
    27. WaitForSingleObject( pi.hProcess, INFINITE );
    28. // Close process and thread handles.
    29. CloseHandle( pi.hProcess );
    30. CloseHandle( pi.hThread );
    31. }
    Alles anzeigen

    (Habe ich mit VisualStudio 2005 compiliert)
    Kannst auch noch im MSDN unter:
    Creating Processes
    nachsehen.
    mfg Elefant1990