我在一个服务程序中调用了一个外部程序,程序运行了,但没有弹出窗口来,并且在任务管理器中也不能杀死,我用的调用外部程序的代码如下://运行一程序并等待它结束
function WinExecAndWait(FileName: string; Visibility: Integer): Cardinal;
var
  zAppName: array[0..255] of char;
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
begin
  StrPCopy(zAppName,FileName);
  FillChar(StartupInfo,Sizeof(StartupInfo),#0);
  StartupInfo.cb := Sizeof(StartupInfo);
  StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
  StartupInfo.wShowWindow := Visibility;
  if not CreateProcess(nil,zAppName,nil,nil,False,
                       CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS,
                       nil,nil,StartupInfo,ProcessInfo) then
    Result := 0
  else
  begin
    WaitForSingleObject(ProcessInfo.hProcess,30000);
    GetExitCodeProcess(ProcessInfo.hProcess,Result);
  end;
end;Result的返回值是$103:ERROR_TOO_MANY_SEM_REQUESTS我该怎么办?

解决方案 »

  1.   

    你用WinExec或者shellexecute
    你现在用的这种方式是她的程序作为你的一个线程使用,要在任务管理器中把你的程序关掉,她才会退出来
      

  2.   

    楼上的两位老大还来和我抢分,郁闷,我习惯用shellexecute;
    ShellExecute(0, nil, 'http://www.sina.com.cn', nil, nil, SW_NORMAL);
      

  3.   

    如果你是在线程中调用的话一定要用同步或者postmessage方式发送消息让它显示出来她才会显示出来的,异步条件下是不会显示出来的
      

  4.   

    我在 Windows 服务程序中运行一个外部程序能弹出窗口来吗?用不用特殊的操作?
      

  5.   

    用winexec或shellExecute也是不行的
      

  6.   

    我做出来了,原来要设置StartupInfo.lpDesktop := PChar('winsta0\default');,将这句加入到我上面的程序中去就可以了。