我在Delphi学习集会,我遇到了一个情况。 当我调用一个返回字符串的对象函数时,我得到一个"访问冲突",但是当函数返回一个整数时,一切正常。
这是代码:
type
TAsmTest = class(TObject)
function CallText: string;
end;
TForm40 = class(TForm)
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
procedure CallName(Test: TAsmTest);
end;
var
Form40: TForm40;
implementation
{$R *.dfm}
procedure TForm40.btn1Click(Sender: TObject);
var
Test: TAsmTest;
begin
Test := TAsmTest.Create;
CallName(Test);
end;
procedure TForm40.CallName(Test: TAsmTest);
asm
push eax;
mov eax, edx;
call TAsmTest.CallText; //Error doesn't happen here
call ShowMessage
pop eax;
end;
{ TClassText }
function TAsmTest.CallText: string;
begin
Result := 'Test Text'; //The Result content is inaccessible, and I dont know why. The EAX is ok.
end;
我们也欢迎任何材料,现在我将此作为参考: http://www.guidogybels.eu/a