当前位置:主页>仓库管理软件> 列表

调用dll出错(Access violation at 0 找哪种财务软件好

销售管理软件版1楼: 我用VC++6.0做了一个简单的Dll,然后用Delphi调用,但是当调用完dll里面的函数以后,就会报 Access violation at 0x0000000 read of address ox0000000错误。可是函数的功能已经完成,实在是不知道什么原因了。

2楼: 地址访问冲突的原因很多 如哪种财务软件好

3楼: 看看调用约定是否匹配

4楼: 你用的是cdecl还是stdcall

5楼: <你用的是cdecl还是stdcall>
是stdcall
很有意思,在调用完dll中的函数以后程序还能往下执行,当把这个包含dll中的函数的事件执行完以后才出错!

6楼: unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
//function add(x,y:integer):integer; stdcall external ''dllTest.dll'';
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function Min1(x,y,z:Integer):Integer; stdcall;
function Max1(x,y,z:Integer):Integer; stdcall;

var
Form1: TForm1;

implementation
function Min1;external ''wode.dll'' name ''Min1'';
function Max1;external ''wode.dll'' name ''Max1'';
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
try
i:=min1(1,2,3);
showmessage(inttostr(i));
except
end;
end;

end.

销售管理软件版7楼: 你的VC++ DLL里用的是cdecl还是stdcall呢

8楼: VC++
我是怎么声明的
extern "C" _declspec(dllexport) int Min1(int x,int y,int z);
extern "C" _declspec(dllexport) int Max1(int x,int y,int z);

9楼: 报错的原因是delphi根本找不到函数的指针

10楼: extern "C" _declspec(dllexport) int Min1(int x,int y,int z);
这样导出的好像函数名会被加个_在前面,所以就找不到函数了.看看你的dll里面的导出表,函数名到底是什么.