winexec("",wm_hide);
shellexecute();
createprocess();
设置使传口最小化或隐藏。

解决方案 »

  1.   

    用winexec("",wm_hide)不行的,你需要用CreateProcess创建进程才可以。
      

  2.   

    To:FireAngel
    我之前写过一个程序,是批量调用批处理的。
    用winexec可以啊。
    不过就是得不到它的processID而已。
    试试如下的程序?
    procedure TmainForm.BatchItem(i:integer);
    var
        sCommandLine,strFJDM,strPath:string;
        configFile:Tinifile;
        y,m,d:word;
    //    MyResult:DWord;
        bCreateProcess: boolean;
        lpStartupInfo: TStartupInfo;
        lpProcessInformation: TProcessInformation;
    begin
        DecodeDate(datetimepicker1.date,y,m,d);
        strFJDM:=listview1.items.item[i].subitems.strings[0];
        configFile:=TIniFile.Create(gvExePath+'config.ini');
        strPath:=configfile.ReadString(strFJDM,'FILE_PATH','');
        sCommandLine:=format('%s %2.2d %2.2d %s',[strPath,m,d,strFJDM]);
        FillChar(lpStartupInfo, Sizeof(TStartupInfo), #0);
        lpStartupInfo.cb := Sizeof(TStartupInfo);
        lpStartupInfo.dwFlags := STARTF_USESHOWWINDOW;
        lpStartupInfo.wShowWindow := SW_SHOW;//把这行改成SW_HIDE就可以了
        statusbar1.Panels[0].text:=format('正在处理%s,请等待...',[listview1.items.item[i].caption]);
        if isTesting then
            showmessage(sCommandLine)
        else begin    bCreateProcess := CreateProcess(nil, PChar(sCommandLine),
                nil, nil, True, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS,
                nil, nil, lpStartupInfo, lpProcessInformation);
        application.ProcessMessages ;
        if bCreateProcess then
        begin
            WaitForSingleObject(lpProcessInformation.hProcess, INFINITE);
            //GetExitCodeProcess(lpProcessInformation.hProcess,MyResult);
            //if MyResult<> 0 then
            //    showMessage(errhandler1(GetLastError()));
        end
        else
            showMessage(errhandler1(GetLastError()));
        end;
            statusbar1.Panels[0].text:='';
    end;