在运行时刻定义DLL中的Function并使用。
我将一个包含DLL的Resource文件包含进了Exe文件。
想在执行时导出,然后使用。试验后不行。
提示找不到DLL,严重错误后退出了。
到Borland新闻组去问,没有回复。
各位高见?
Declard a function of a DLL at RUNTIME.
How to Declard a function in the RESOURCE {$R}.Declard a RunTime Function.
I include a myrs.res file with a DLL in my execute program.
First:The Program extract DLL file to Windows directory.
Second:Declare the function in the Click Event Procedure of a Button.
.......using the function.
Can I Do That?
RunTime Declare.
问题点数:20、回复次数:3Top
1 楼Liusp(夜深千帐灯)回复于 2002-04-17 18:14:37 得分 0
我也希望有解决的办法,但我估计这种方法存在的可能性不大Top
2 楼cplusc(5i海洋)回复于 2002-04-17 21:46:28 得分 0
upTop
3 楼nne998(☆☆☆☆☆☆☆伴月)回复于 2002-04-17 21:56:00 得分 20
显式例子:
procedure TForm1.Button1Click(Sender: TObject);
var D: Double;
DLLHandle: THandle;
Func: TGetDouble;
begin
Image1.Picture.Assign(Table1Graphic);
Table1Graphic.Assign(Image1.Picture);
Exit;
DLLHandle := LoadLibrary('DLLOne.dll');
try
@Func := GetProcAddress(DLLHandle, 'GetDouble');
//Edit1.Text := IntToStr(GetInteger(2));
//D := GetDouble(2.2);
if Assigned(@Func) then
begin
D := Func(2.2);
Edit2.Text := FloatToStr(D);
end;
finally
FreeLibrary(DLLHandle);
end;
end;
end.
隐式例子:
library DLLOne;
uses
SysUtils,
Classes;
{$R *.res}
function GetDoubleExt(F:Double): Double;stdcall;external 'DLLTwo.dll';
function GetInt(I:Integer): Integer;stdcall;external 'DLLTwo.dll';
function GetInteger(I:Integer): Integer;stdcall;
begin
Result := GetInt(I);
end;
function GetDouble(D:Double): Double;stdcall;
begin
Result := GetDoubleExt(D);
end;
exports
GetInteger,
GetDouble;
begin
end.
Top




