Announcement

Collapse
No announcement yet.

Mit ShellExecute ein anderes Programm

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mit ShellExecute ein anderes Programm

    Moin moin,

    Ich hätte da mal ne Frage :

    Wie kann ich mit ShellExecute ein Programm starten (z.B. Acrobat) und dann mein Programm solange schlafen legen, bis das aufgerufene Programm beendet wurde ?? (Also wie ShowModal())


    Danke

    Henri

  • #2
    gar nicht, dazu braucht man CreateProcess

    http://www.marquardtnet.info/cecke/q...quicky_25.html
    Christian

    Comment


    • #3
      Habe ich mir schon gedacht. Aber wie kann ich damit eine Standardanwendung für eine Dateiendung (z.B. .PDF oder .HTML) starten ???

      Comment


      • #4
        versuch, diese in der Commandline einzutragen und ApplicationName auf NULL
        Christian

        Comment


        • #5
          Funktioniert leider nicht

          Ich habe alle möglichen Kombinationen ausprobiert.

          Die Hilfe zu CreateProcess sagt folgendes :

          Code:
          BOOL CreateProcess(
              LPCTSTR lpApplicationName,	// pointer to name of executable module 
              LPTSTR lpCommandLine,	// pointer to command line string
              LPSECURITY_ATTRIBUTES lpProcessAttributes,	// pointer to process security attributes 
              LPSECURITY_ATTRIBUTES lpThreadAttributes,	// pointer to thread security attributes 
              BOOL bInheritHandles,	// handle inheritance flag 
              DWORD dwCreationFlags,	// creation flags 
              LPVOID lpEnvironment,	// pointer to new environment block 
              LPCTSTR lpCurrentDirectory,	// pointer to current directory name 
              LPSTARTUPINFO lpStartupInfo,	// pointer to STARTUPINFO 
              LPPROCESS_INFORMATION lpProcessInformation 	// pointer to PROCESS_INFORMATION  
             );

          Comment


          • #6
            Dann musst du schauen, ob du von einem mit shellexcute gestartetem Programm die Processinformationen bekommst, oder du liest aus der Registry unter
            HKEY_CLASSES_ROOT\.pdf\OpenWithList

            die Programme aus. Ev. gibt es ja auch eine MS Funktion die die Daten ermittelt...
            Christian

            Comment


            • #7
              Createprocess Beispiel

              Hier ist ein funktionierendes Beispiel für CreateProcess:

              Code:
                PROCESS_INFORMATION pi;
                STARTUPINFO si;
                char Buffer[4000];
                DWORD dwRead, FExitCode;
              
                memset(&si, 0, sizeof(STARTUPINFO));
                si.cb = sizeof (STARTUPINFO);
                si.wShowWindow = SW_SHOW;
              
                /* Beispiel für aufzurufendes Programm */
                AnsiString CmdStr = "C:\\Programme\\MyProg.exe";
              
                AnsiString Dir = ExtractFilePath(CmdStr);
                AnsiString Cmd = ExtractFileName(CmdStr)
                if (CreateProcess(NULL, Cmd.c_str(), NULL, NULL, true, NULL, NULL, Dir.c_str(), &si, &pi))
                {
                   FExitCode = STILL_ACTIVE;
                   do
                   {
                     GetExitCodeProcess(pi.hProcess, &FExitCode);
                     Application->ProcessMessages();
                   } while (FExitCode == STILL_ACTIVE);
                   AnsiString H = "ExitCode = " + IntToStr(FExitCode);
                   Application->MessageBox(H.c_str(),"ProgrammEnde",MB_OK);
                } else ErrMsg("CreateProcess");
              Bye - Peter

              Comment


              • #8
                Es geht nicht um einen Aufruf von CreateProcess, sondern diese Funktion zu nutzen um bsp. mit "test.htm" den damit verbundenen Browser zu starten.

                Also die Anwendung zu starten mit der die Dateiendung verbunden ist
                Christian

                Comment

                Working...
                X