在VB中有一个Shell函数,在系统的Shell中拟行指定的命令,在很多编程语言中都有这个函数,不知Delphi中与之对应的是什么函数?

解决方案 »

  1.   

    use ShellApi;  ShellExecute(handle, nil, 'mspaint.exe', nil, nil, SW_SHOW);
      

  2.   

    unit Console;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls,ShellAPI;type
      TConsoleForm = class(TForm)
        btOpen: TButton;
        btClose: TButton;
        btRun: TButton;
        btOutput: TButton;
        procedure btOpenClick(Sender: TObject);
        procedure btCloseClick(Sender: TObject);
        procedure btOutputClick(Sender: TObject);
        procedure btRunClick(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      ConsoleForm: TConsoleForm;implementation{$R *.dfm}procedure TConsoleForm.btOpenClick(Sender: TObject);
    begin
      if not AllocConsole then Application.MessageBox('Can''t allocate console!','Console',MB_OK OR MB_ICONINFORMATION)
      else SetConsoleTitle('Console Demo');
    end;procedure TConsoleForm.btCloseClick(Sender: TObject);
    begin
      if not FreeConsole then Application.MessageBox('Can''t free console!','Console',MB_OK OR MB_ICONINFORMATION);
    end;procedure TConsoleForm.btOutputClick(Sender: TObject);
    var OutText:PChar;nWrite:Cardinal;sHandle:Cardinal;
    begin
     OutText:='Hello,console!'#$A#$D;
     sHandle:=GetStdHandle(STD_OUTPUT_HANDLE);
     if (sHandle<>0) then
     begin
       WriteConsole(sHandle,OutText,StrLen(OutText),nWrite,nil);
     end;
    end;procedure TConsoleForm.btRunClick(Sender: TObject);
    begin
      //这里要运行dos的dir命令,并将结果输出到"Open"按钮打开的Console 
      //Window,怎么写
    end;end.