沧
沧海
Unregistered / Unconfirmed
GUEST, unregistred user!
为什么我的返回值是错的!
请各位高手指点
请各位高手指点
代码:
unit TestUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TFunc = function (MyInt:integer):integer
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure DoDllFunc;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
// function ShowDllHello(ftStr:string):integer;stdcall;External'Dll_Hello.dll';
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
DoDllFunc;
end;
procedure TForm1.DoDllFunc;
var
MyFunc:TFunc;
MyHandle:THandle;
begin
MyHandle:=LoadLibrary('Dll_Hello.dll');
if MyHandle>32 then
begin
@MyFunc:=GetProcAddress(MyHandle,'ShowDllHello');
if @MyFunc<>nil then
begin
showmessage(IntToStr(MyFunc(10)))
//////////想不通,返回 为什么错!
end;
FreeLibrary(MyHandle);
end;
end;
end.
library Dll_Hello;
uses
SysUtils,Classes;
{$R *.RES}
function ShowDllHello(HelloStr:integer):integer;stdcall;
begin
Result:=HelloStr * 99;
end;
exports
ShowDllHello name 'ShowDllHello'
begin
end.
【、】