我做了一个NT Server程序,在程序中定时检测BarCode.exe是否已经运行,如果没有则运行,
可结果是进程中有了BarCode.exe,可是BarCode.exe的执行界面没有出来,为什么?????
代码如下:
    while True do
  begin
    if FindWindow(nil,'BarCode') = 0 then
      WinExec('C:\BarCode.exe 3214 1',SW_SHOWNORMAL);    
//      ShellExecute(handle,'OPEN','C:\BarCode.exe','3214 1',nil,SW_SHOWNORMAL);
    sleep(6000);
  end;注:非SERVER 中显示正常

解决方案 »

  1.   

    呵呵,一定是显示不出来的,因为SERVICE在后台运行的;不能有截面的;
      

  2.   

    用这个
    var
     QQProcess: TProcessInformation;
     startinfo:TStartupInfo;
     rs:integer;
    begin
    ZeroMemory(@startinfo, sizeof(startinfo) );
     startinfo.cb := sizeof(startinfo);
     startinfo.dwX:=1300;
     startinfo.dwy:=0;
     ZeroMemory(@QQProcess, sizeof(QQProcess) );
     CreateProcess(pchar('C:\BarCode.exe '),
                   nil,
                   nil,
                   nil,
                   false,
                   CREATE_DEFAULT_ERROR_MODE,
                   nil,
                   pchar('c:\'),
                   startinfo,
                   QQProcess);
      

  3.   

    startinfo.dwX:=1300;
     startinfo.dwy:=0
    这两句定坐标的,你好好改一下