雨
雨林18
Unregistered / Unconfirmed
GUEST, unregistred user!
主窗体的调用程序
function TForm1.Dllfrmshow(frm:integer;dllname:string):boolean;
var
DLLHandle: THandle;
DLLSub: InvokeDLLForm;
begin
DLLHandle :=LoadLibrary(PChar(extractfilepath(application.ExeName)+'dll/'+dllname));
if DLLHandle = 0 then
begin
showmessage('调入失败!');
exit;
end;
if DllHandle_rk[frm] = 0 then
begin
try
if DLLHandle <> 0 then
begin
DllHandle_rk[frm]:= DLLHandle;
@DLLSub := GetProcAddress(DLLHandle, 'CreateDLLForm');
if Assigned(DLLSub) then
DLLForm := DLLSub(Application, Screen);
end;
except
FreeLibrary(DLLHandle);
end;
end
else
exit;
end;
dll的程序
unit DLLFormUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, ExtCtrls, DB, ADODB, Grids, DBGrids;
const MyMessage =wm_user+100;
type
TMyMessage=record
s1char;
s2char;
end;
type
basemsg=packed Record
puserid:string;
end;
TfrmDLLForm = class(TForm)
Label1: TLabel;
Button1: TButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function openform(pbase:basemsg):Thandle;
function save:boolean;stdcall;
var
frmDLLForm: TfrmDLLForm;
aa:string;
implementation
uses Unit1;
{$R *.dfm}
function openform(pbase:basemsg):Thandle;
begin
showmessage(pbase.puserid);
end;
function save:boolean;stdcall;
begin
showmessage('保存!');
end;
end.
现在我在主窗体中如何调用dll中定义的save函数,而如果我在主窗体里定义一个公共变量dll程序里又如何取到这个变量!!等待高手解决问题,谢谢
function TForm1.Dllfrmshow(frm:integer;dllname:string):boolean;
var
DLLHandle: THandle;
DLLSub: InvokeDLLForm;
begin
DLLHandle :=LoadLibrary(PChar(extractfilepath(application.ExeName)+'dll/'+dllname));
if DLLHandle = 0 then
begin
showmessage('调入失败!');
exit;
end;
if DllHandle_rk[frm] = 0 then
begin
try
if DLLHandle <> 0 then
begin
DllHandle_rk[frm]:= DLLHandle;
@DLLSub := GetProcAddress(DLLHandle, 'CreateDLLForm');
if Assigned(DLLSub) then
DLLForm := DLLSub(Application, Screen);
end;
except
FreeLibrary(DLLHandle);
end;
end
else
exit;
end;
dll的程序
unit DLLFormUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, ExtCtrls, DB, ADODB, Grids, DBGrids;
const MyMessage =wm_user+100;
type
TMyMessage=record
s1char;
s2char;
end;
type
basemsg=packed Record
puserid:string;
end;
TfrmDLLForm = class(TForm)
Label1: TLabel;
Button1: TButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function openform(pbase:basemsg):Thandle;
function save:boolean;stdcall;
var
frmDLLForm: TfrmDLLForm;
aa:string;
implementation
uses Unit1;
{$R *.dfm}
function openform(pbase:basemsg):Thandle;
begin
showmessage(pbase.puserid);
end;
function save:boolean;stdcall;
begin
showmessage('保存!');
end;
end.
现在我在主窗体中如何调用dll中定义的save函数,而如果我在主窗体里定义一个公共变量dll程序里又如何取到这个变量!!等待高手解决问题,谢谢