本人用DELPHI 5.0建立控制台程序(由File|New通过New Items窗口的New页的Console Application建立project)。在project中用ShellExecute调用外部EXE程序。例程中ShellExecute函数中外部EXE程序的句柄Handle是由parent window给出的Form1.Handle,然而Console Application建立的project中没有窗体,那么ShellExecute函数中外部EXE程序的句柄--应该如何给出?请诸位高手赐教!
(希望写出简易代码!)

解决方案 »

  1.   

    句柄用0就可以了。
    shellexecute(0, ...)这个句柄是指定接收调用程序的错误对话框的窗口,一般没什么用。
      

  2.   

    通过LoadLibrary()函数。
    例如:
    procedure TForm1.Button1Click(Sender: TObject);
    var
      han: THandle;
    begin
      han :=LoadLibrary('C:\WINDOWS\EXPLORER.EXE');
      ShellExecute(han, nil, PChar('C:\WINDOWS\EXPLORER.EXE'), nil, nil, SW_SHOWNORMAL);
    end;
      

  3.   

    我用ShellExecute(0,'open','c:\project1.exe',nil,nil,SW_SHOWNORMAL);验证,并不能达到预期目的,请教高手如何解决!
      

  4.   

    我的目的是想通过ShellExecute函数在delphi中用控制台程序调用project1.exe文件,以便在dos环境中执行(不需要窗体)。
      

  5.   


    ShellExecute(handle,nil,'c:\project1.exe',nil,nil,SW_SHOWNORMAL);
      

  6.   

    用ShellExecute(handle,nil,'c:\project1.exe',nil,nil,SW_SHOWNORMAL);
    系统提示[Error] Project1.dpr(7): Undeclared identifier: 'handle'
    请问如何解决?