用delphi写的一个小程序生成的可执行程序
如Demo.Exe在用delphi写一个来调用Demo.exe
要求打开并隐藏
我用
Instance1:=ShellExecute(handle,pchar('open'),pchar('Demo.exe'),'','',SW_HIDE);
不行,打开了但没有隐藏ShowWindow(Instance1,SW_HIDE);也不行,请问怎么办

解决方案 »

  1.   

    在你的demo.exe中判断ParamStr(1)是否等于'/min',如果是就将WindowState:=wsMinimized。然后这样调用demo.exe:
    ShellExecute(handle,pchar('open'),pchar('Demo.exe'),'/min','',SW_HIDE);
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      winexec('Demo.exe',SW_SHOW);
      showwindow(findwindow('Demo.exe主窗口的类名',nil),SW_HIDE);
    end;
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    function WinExec_NoShow(FileName:String):THANDLE;
    var
      zAppName:array[0..512] of char;
      zCurDir:array[0..255] of char;
      WorkDir:String;
      StartupInfo:TStartupInfo;
      ProcessInfo:TProcessInformation;
      returnresult:DWORD;
      i: integer;
    begin
      StrPCopy(zAppName,FileName);
      WorkDir := ExtractFilePath(ParamStr(0));
      StrPCopy(zCurDir,WorkDir);
      FillChar(StartupInfo,Sizeof(StartupInfo),#0);
      StartupInfo.cb := Sizeof(StartupInfo);
      StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
      StartupInfo.wShowWindow := SW_SHOWDEFAULT;
      if CreateProcess(nil,
            zAppName,          { pointer to command line string }
            nil,   { pointer to process securityattributes }
            nil,   { pointer to thread security attributes }
            false, { handle inheritance flag }
            CREATE_SUSPENDED,
            nil,   { pointer to new environment block }
            nil,   { pointer to current directory name }
            StartupInfo,       { pointer to STARTUPINFO }
            ProcessInfo)       { pointer to PROCESS_INF }
      then
        Result := ProcessInfo.hThread
      else
        Result := NULL;
    end;
    var
      Instance1: THandle;
    begin
      Instance1 := WinExec_NoShow(''Demo.exe');
    end;
      

  4.   

    不行,我是想隐藏等录窗体,我执入密码后,单击,进入Demo.exe的主窗体
      

  5.   

    就是在一个程序中打开另一程序时隐藏登录窗体,用enmuwindow找到Tedit执入密码后,单击
    进如
      

  6.   

    楼上给的代码好像在加密什么的见过,只是创建了一个新进程,返回的是进程的句柄。楼主的ShowWindow(Instance1,SW_HIDE);要的是窗体的句柄,应该不行。xixuemao给的代码找的就是窗体句柄了。
      

  7.   

    楼主想偷人家密码,鉴定完毕。ShellExecute(handle,'open','Demo.exe',nil,nil,SW_HIDE);
      

  8.   

    像ShowWindow(HANDLE,SW_HIDE);函数的应用其相对是的窗口的句柄!
    而DELPHI中主程序的句柄与各窗口的句柄是不同的,你最好先用SP++看一下你要隐藏的窗口的句柄,然后再说哦!
      

  9.   

    ShellExecute(handle,'open','Demo.exe',nil,nil,SW_HIDE);
    为什么SW_HIDE没有用啊,怎么隐藏不到
      

  10.   

    ShellExecute(handle,'open','Demo.exe',nil,nil,SW_HIDE);
    为什么SW_HIDE没有用啊,怎么隐藏不到
    _______________________________DELPHI中主程序的句柄与各窗口的句柄是不同的,你最好先用SP++看一下你要隐藏的窗口的句柄,然后再说哦!
      

  11.   

    我知道,但我要先启动主程序,才能用SP++查看啊,但ShellExecute(handle,'open','Demo.exe',nil,nil,SW_HIDE);直接就弹出来,我不想让它弹出
    只是通过我的确认后才让它显示
      

  12.   

    winexec('Demo.exe',SW_HIDE)
    这个应该可以吧
    不过没返回句柄,需要的话自己打开个吧