有3个exe文件:exe1是主程序;exe2是分程序2;exe3是分程序3。
在exe1中输入4个信息:xx1,xx2,xx3
exe1根据xx1的内容调用exe2或exe3,并将xx2和xx3传入exe2和exe3请问:(1)exe之间如何传递参数
      (2)被调用的exe如何定义接收到的参数
      (3)exe1调用exe2后如何自动关闭我刚学习delphi不久,请大家多帮忙。

解决方案 »

  1.   

    如果都是你自己写的话,还是用dll吧
      

  2.   

    >>:(1)exe之间如何传递参数打开notepad.exe 
    uses ShellApi; 
    ... 
    ShellExecute(Handle, ’open’, 
    ’c:\Windows\notepad.exe’, nil, nil, SW_SHOWNORMAL); 第4位可输入你要传的参数
      

  3.   

    >>(2)被调用的exe如何定义接收到的参数paramstr 就是
    s:= ParamStr(1); (3)exe1调用exe2后如何自动关闭
     Application.Terminate;
      

  4.   

    在Exe1的public中定义两个xxx2,xxx3;
    先在Exe1中判断xxx1是要调用Exe2或Exe3
    if xxx1 = 'exe2' then
      begin
        Exe2 := Texe2.Create(Application);
        .......
        Exe1.Hide;
        ......
        EXE2.FREE;
      end;
    这样不就可以了吗?不管是Exe2,exe3都可以调用xxx2,xxx3
    其实这样也就是在窗口之间传递参数。
      

  5.   

    主调用程序:
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
      function sum(x,y:integer):integer;stdcall; external 'project1.dll';
    var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
      showmessage(IntToStr(sum(12,20)));
    end;end.
    被调用程序(dll):
    library Project1;uses
      SysUtils,
      Classes;{$R *.res}
      function sum(x,y : integer):integer;stdcall;
      begin
        result := x + y;
      end;
    exports sum;
    begin
    end.
    ============================
    上面只是最简单的示例,建议楼主多看看书:)
    ============================
      

  6.   

    同意
    jinjazz(近身剪(充电中...))