我现在有Project1.exe、Project2.exe两个程序
Project1.exe里有这样的调用:
WinExec('Project2.exe kkk',SW_SHOWDEFAULT);
其中传递了'kkk'参参数给Project2.exe请问Project2.exe怎么得到这个参数值

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Memo1: TMemo;
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
      ShowMessage('ok');
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      WinExec('D:\Documents and Settings\zhang\桌面\带参数的程序运行\2\Project1.exe abcdefg aaaaa',SW_SHOWNORMAL);
    end;end.
    program Project2;uses
      Forms,
      Unit1 in 'Unit1.pas' {Form1};{$R *.res}begin
      Application.Initialize;
      Application.Initialize;
      if ParamStr(1) = 'abcdefg' then
      begin
        Application.CreateForm(TForm1, Form1);
        Form1.Caption := ParamStr(1) + ParamStr(2);
        Application.Run;
      end
      else
        Application.Terminate;
    end.
      

  2.   

    zfpcb(我是你的传说):
    不好意思,刚才打开时没看到后面的