问题:我安装了一个phptrial,在启动start apache后,会出现个msdos窗口,而且这个窗口不能关闭,否则便不能启动php.
我想用delphi做个隐藏任务的程序,让这个窗口消失,在windowxp下可以,但是程序在98下运行便出现了问题。因为98下的窗口名字和xp下的不同,而且在98下,会存在两个名字为'apache'的dos窗口,其中一个不可见。我没办法了,只有请教了。源程序如下:
program hidewindow;
uses
  forms,Windows;{$R *.res}
var i:integer;
begin
 Application.Initialize;
 Application.Run; 
 //看看apache窗口是否已经存在,不存在就运行apache+mysql 
 i:=findwindow(nil,'apache');
 if (i=0) then
 begin
        winexec('C:\Apache\mysql\bin\mysqld.exe --
               standalone',sw_shownormal);//启动mysql
        winexec('C:\Apache\Apache.exe',sw_shownormal);//启动apache,完毕后
//会出现两个apache进程,可见的只有一个,以msdos窗口方式显示
        while i=0 do
        begin
                i:=findwindow(nil,'C:\Apache\Apache.exe');//问题出现了,
//这时系统中存在两个apache进程,其中一个不可见,但findwindow发现的并不一定是我
//想隐藏的窗口,
        end;
        //等待窗口初始化完毕
        while (IsWindowVisible(i)=false) do
        begin
        end;
        //隐藏窗口
        showwindow(i,sw_hide);
 end;
 winexec('c:\program files\internet explorer\iexplore.exe http://localhost/medcine/',sw_shownormal);end.
请问我该怎么办???

解决方案 »

  1.   

    ShowWindow(Application.Handle,SW_HIDE);
      

  2.   

    application.handle只代表程序本身产生的句柄,但我要隐藏的是外部程序产生的窗口啊
      

  3.   

    在WIN98下,不要用窗口标题找DOS窗口,最好用窗口类名找,因为每个DOS窗口的
    类名都是一样,具体叫什么我忘记了,你可以用WinSight(WS.EXE)查一下,我以前做过类似,没问题的。//这时系统中存在两个apache进程,其中一个不可见,但findwindow发现的并不一定是我
    //想隐藏的窗口,
    >>:可以用GetWindow(handle,HWND_NEXT)遍历窗口,用GetWindowText取窗口标题,IsWindowVisible
      

  4.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      hwndclose:hwnd;
      str:string;
    begin
      str:=edit1.text;
      hWndClose := FindWindow(nil, PChar(str));
      ShowWindow(hwndclose,SW_hide);
    end;
    其中edit中输入 你要隐藏窗口的 在任务栏中 显示的名字
      

  5.   

    getwindow和gettopwindow怎么用啊?我运行时老是有错误
      

  6.   

    handTray := FindWindow(nil, PChar(str));
    ShowWindow(handTray ,SW_hide);
      

  7.   

    终于搞定,原来如此
    procedure TForm1.Button1Click(Sender: TObject);
      var
        hCurrentWindow: HWnd;
        szText: array[0..254] of char;
        title:string;
    begin
      title:='C:\Apache\Apache.exe';
      hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);
      while hCurrentWindow<>0 do begin
        if GetWindowText(hCurrentWindow, @szText, 255)>0 then
          if strPas(@szText)=title then
            begin
              //showmessage(strPas(@szText));
               if (IsWindowVisible(hCurrentWindow)) then
                title:=title+'可见';
              //showmessage(title);
              showwindow(hcurrentwindow,sw_hide);
            end;
        hCurrentWindow:=getwindow(hCurrentWindow,gw_hwndnext);
      end;
    end;
    不管有多少个窗口,只要标题等于=title,一概hide,tnnd,浪费我一天的时间,感谢yang6130(月明@沧海) ,gamaster(a明) .