用vc做的一个dll
只声明一个函数 int get(int a) 返回a的值
在delphi中动态调用
程序如下procedure TForm1.Button1Click(Sender: TObject);
type
get=function(i:integer):integer;
var
y:integer;
aptr:TFarproc;
lhnd:THandle;
flag:integer;
begin
lhnd:=Loadlibrary('dll5.dll');
aptr:=GetprocAddress(lhnd,PChar('get'));
y:=get(aptr)(111);
memo1.Text:=inttostr(y);
FreeLibrary(lhnd);
end;
为什么返回值总是1243373
只声明一个函数 int get(int a) 返回a的值
在delphi中动态调用
程序如下procedure TForm1.Button1Click(Sender: TObject);
type
get=function(i:integer):integer;
var
y:integer;
aptr:TFarproc;
lhnd:THandle;
flag:integer;
begin
lhnd:=Loadlibrary('dll5.dll');
aptr:=GetprocAddress(lhnd,PChar('get'));
y:=get(aptr)(111);
memo1.Text:=inttostr(y);
FreeLibrary(lhnd);
end;
为什么返回值总是1243373
解决方案 »
- 请问如何改进----这个IDHttp的简单取网页的代码?
- This is a multi-part message in MIME format
- Delphi报表
- 问个简单问题,在代码中用什么快捷键把一段代码向后移动几个空格的位置
- 打开AdoQuery对象导致异常:无当前记录。
- 关于数据库连接问题,BDE?
- 怎么在程序开始运行时载入一个Jpg文件作为窗口背景?
- 停泊式Panel,在鼠标拖拉后才出现标题栏,我想一开始就出现标题栏怎么实现?
- 下面SQL语句怎么执行?
- 如何将任意数据库中数据表中的数据导入到ACCESS库中(用ADO)
- Indy10比Indy9提高了哪些地方?有必要升级吗?
- TIDHttp+TIdSSLIOHandlerSocket实现https出错,请高人指点!
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
get=function(i:integer):integer;stdcall;
var
Form1: TForm1;
function_get:get;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
hand:HMODULE;
ret:integer;
begin
hand:=LoadLibrary('Dll5.dll'); //打开动态链接库
if (hand=0) then
begin
showmessage('无法载入Dll5.dll文件');
exit;
end;
@function_get:=GetProcAddress(hand,'get');
if (@function_get=nil) then
begin
FreeLibrary(hand);
showmessage('取不到get 地址');
exit;
end;
ret:=function_get(111);
showmessage(inttostr(ret));
end;end.
这是我帮你写的,还有问题的告诉我