我做了一个DLL,调用主程序中的函数,总是报错。大虾们能不能帮我看看?DLL和主程序代码如下:
library Project1;uses
Wintypes,
SysUtils,
Dialogs,
Classes;type
Tintfunc=function (x:integer):integer;stdcall;function temp(x:integer;P:TFarProc):integer;stdcall;
begin
//showmessage('ok');
if P<>nil then result:=2*Tintfunc(p)(x);
end;
{$R *.RES}
exports
temp;
begin
end.*********************************************
unit Unit2;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}function temp(x:integer;p:TfarProc):integer;stdcall;external 'project1.dll';function doub(x:integer):integer;
begin
result:=2*x;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.text:=inttostr(temp(10,@doub));
end;end.
library Project1;uses
Wintypes,
SysUtils,
Dialogs,
Classes;type
Tintfunc=function (x:integer):integer;stdcall;function temp(x:integer;P:TFarProc):integer;stdcall;
begin
//showmessage('ok');
if P<>nil then result:=2*Tintfunc(p)(x);
end;
{$R *.RES}
exports
temp;
begin
end.*********************************************
unit Unit2;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}function temp(x:integer;p:TfarProc):integer;stdcall;external 'project1.dll';function doub(x:integer):integer;
begin
result:=2*x;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.text:=inttostr(temp(10,@doub));
end;end.
解决方案 »
- 通过对DBGridEh中的一列求和,结果放在footer上,请问怎么把这个结果取出来用?
- 对时间字段进行查询,用filter和where有差别吗?
- delphi5编程时如何操作才能出现代码提示呢?
- 关于查询的问题,(100)
- 马上结账:为什么用ADOTable在删除一条记录后,调用refresh,数据集仍没有刷新。弹出异常:无法为更新行集定位,一些值可能已在最后读取
- 帮忙将 BCB 的程序转换的 DELPHI 。
- WM_COPYDATA如何传送Image图象?
- 回复:关于进销存的常见问题,进来看看好吗?
- 大家帮忙该delphi的错
- --------------- 中国315 --------------
- 哪里可以找到qrctrls.pas
- 我的自定义控件中用到了滚动条,我想设定它的ctl3d属性,怎么做?
Wintypes,
SysUtils,
Dialogs,
Classes;type
Tintfunc=function (x:integer):integer;stdcall;function temp(x:integer;P:TFarProc):integer;stdcall;
begin
//showmessage('ok');
if P<>null then result:=2*Tintfunc(p)(x);/你这个地方错了*/
end;
{$R *.RES}
exports
temp;
begin
end.*********************************************
unit Unit2;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}function temp(x:integer;p:TfarProc):integer;stdcall;external 'project1.dll';function doub(x:integer):integer;
begin
result:=2*x;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.text:=inttostr(temp(10,@doub));
end;end.