【发布时间】:2010-12-14 12:38:22
【问题描述】:
有一个从 BPL 导出的函数,下面简化了
function DoA(amount: currency; var Info: string): Currency; stdcall;
begin
result := amount * 19;
Info:= 'Some Text about the result';
end;
它使用 LoadPackage 和 GetProcAddress 从主程序加载,它适用于其他功能。 但是这个在调用时会带来很多错误;
BPL 与(简化)一起使用
bplhandle: HModule;
BPLDoA: function (amount: currency; var Info: string): Currency; stdcall;
intoStr : string;
.
begin
bplhandle:=LoadPackage('test.bpl');
if bplhandle <> 0 then
begin
@BPLDoA:=GetProcAddress(bplhandle,'DoA');
if assigned(BPLDoA) then
result := BPLDoA(123, intoStr);
end;
end;
在程序结束时似乎发生的异常, 但更正后的文本被返回到 intoStr 中(用断点查看)
该错误是否与 Info 参数是 var 和/或字符串有关?
错误信息是
Project Project1.exe 引发异常类 EInvalidPointer 并带有消息“无效指针操作”
谢谢
更多信息> 来自同一个 bpl/unit 的另一个函数工作正常
function DoB(amount: currency): Currency; stdcall;
result := amount * 19;
end;
疯狂的除外>
异常类:EInvalidPointer 异常消息:无效的指针操作。
主线程 ($1b7c): 0040276f +013 Project1.exe 系统@FreeMem 00404650 +01c Project1.exe 系统@LStrClr 00483814 +15c Project1.exe Unit1 97 +11 TForm1.Button3Click 00462430 +064 Project1.exe 控制 TControl.Click 0045a870 +01c Project1.exe StdCtrls TButton.Click
【问题讨论】:
-
您的金额上没有“var”
-
对不起这个例子不是最好的改变它