R
ricleon
Unregistered / Unconfirmed
GUEST, unregistred user!
以下是DLL及调用程序,在关闭调用程序时出错,还请高手指点!!!
//DLL内的两个单元
//单元1
library KeyBoradHook;
uses
SysUtils,Windows,
Classes,ShareMem,
Unitdll in 'Unitdll.pas';
{$R *.res}
exports
GetConString;
begin
end.
//单元2
unit Unitdll;
interface
function GetConString(DatePath,OptionPath:String):string;stdcall;
implementation
function GetConString(DatePath,OptionPath:String):string;stdcall;
var ConString:string;
begin
Result:='';
ConString:='aaaaaa'+
DatePath+'bbbbbb'+
OptionPath+'cccccc';
Result:=ConString;
end;
end.
//调用单元
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ShareMem;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
function GetConString(DatePath,OptionPath:String):string; stdcall; external 'KeyBoradHook.dll';
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Text:=GetConString('d:/ddd','E:www');
end;
end.
//DLL内的两个单元
//单元1
library KeyBoradHook;
uses
SysUtils,Windows,
Classes,ShareMem,
Unitdll in 'Unitdll.pas';
{$R *.res}
exports
GetConString;
begin
end.
//单元2
unit Unitdll;
interface
function GetConString(DatePath,OptionPath:String):string;stdcall;
implementation
function GetConString(DatePath,OptionPath:String):string;stdcall;
var ConString:string;
begin
Result:='';
ConString:='aaaaaa'+
DatePath+'bbbbbb'+
OptionPath+'cccccc';
Result:=ConString;
end;
end.
//调用单元
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ShareMem;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
function GetConString(DatePath,OptionPath:String):string; stdcall; external 'KeyBoradHook.dll';
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Text:=GetConString('d:/ddd','E:www');
end;
end.