现在在家,明天发email到[email protected],may be i can help you

解决方案 »

  1.   

    //With CreateProcess: 
    //***************************************************** function ExecFileAndWait(const aCmdLine: String; Hidden, doWait: Boolean): Boolean; 
    var 
       StartupInfo : TStartupInfo; 
       ProcessInfo : TProcessInformation; 
    begin 
       {setup the startup information for the application } 
        FillChar(StartupInfo, SizeOf(TStartupInfo), 0); 
       with StartupInfo do 
        begin 
         cb:= SizeOf(TStartupInfo); 
         dwFlags:= STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK; 
         if Hidden 
          then wShowWindow:= SW_HIDE 
          else wShowWindow:= SW_SHOWNORMAL; 
        end;     Result := CreateProcess(nil,PChar(aCmdLine), nil, nil, False, 
        NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo); 
        if doWait then 
          if Result then 
          begin 
            WaitForInputIdle(ProcessInfo.hProcess, INFINITE); 
            WaitForSingleObject(ProcessInfo.hProcess, INFINITE); 
          end; 
    end; procedure TForm1.Button1Click(Sender: TObject); 
    begin 
      ExecFileAndWait('notepad.exe',false,true); 
    end; //With ShellExecuteEx: 
    //***************************************************** uses shellapi; {...} procedure TForm1.Button1Click(Sender: TObject);  Var 
       exInfo: TShellExecuteInfo; 
       exitcode: DWORD; 
     Begin 
       FillChar( exInfo, Sizeof(exInfo), 0 ); 
       With exInfo Do Begin 
         cbSize:= Sizeof( exInfo ); // required! 
         fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT; 
         Wnd   := Handle;  // forms handle 
         lpVerb:= 'open'; 
         lpFile:= Pchar('notepad' ); 
         nShow := SW_SHOWNORMAL 
       End; 
       If ShellExecuteEx( @exInfo ) Then Begin 
          While GetExitCodeProcess( exinfo.hProcess, exitcode ) 
                and (exitcode = STILL_ACTIVE) 
          Do 
            Application.Processmessages; 
          CloseHandle( exinfo.hProcess ); 
       End 
       Else 
         ShowMessage(SysErrorMessage( GetLastError )); 
        showmessage('ended'); 
      end; 
      

  2.   

    对createprocess的参数有没有写错了呀?