delphi dll 实例 与 dll窗体实例

delphi dll 实例 与 dll窗体实例

本动态链接库方法有

Min,Max,SynAPP,ShowForm,showmyform

dll工程文件

Library Project1;
uses
  dllUnit1 in 'dllUnit1.pas' {Form1};

function Min(X, Y: Integer): Integer; export;
begin
if X < Y then Min := X else Min := Y;
end;
function Max(X, Y: Integer): Integer; export;
begin
if X > Y then Max := X else Max := Y;

end;
procedure showmyform();export;
begin
       Form1 := TForm1.Create(nil);
       Form1.ShowModal;
end;

exports
Min,Max,SynAPP,ShowForm,showmyform;

begin

end.

窗体单元文件:

unit dllUnit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

  procedure SynAPP(App:THandle);stdcall;
  procedure ShowForm;stdcall;
implementation



{$R *.dfm}

procedure SynAPP(App:THandle );stdcall;
begin
  Application.Handle := App;
end;
procedure ShowForm;stdcall;
begin

    Form1 := TForm1.Create (Application);


         // Form2 := TForm2.Create(Application);
          Form1.ShowModal;

end;


procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;

end.

原文地址:https://www.cnblogs.com/fengju/p/6173821.html