一个动态链接库DLL文件的问题?
我写了一个DLL文件,里面有一个函数我用的开发软件是DELPHI6。
当DLL文件只有一个函数时DELPHI可以调用一切正常,当我在DLL文件里在添加一个函数时就出错不能调用,出错信息如下:
"profect1.exe-损坏的图象 //信息框的标头
应用程序或DLL E:\DELPHIDLL\DELL.DLL为无效的WINDOWS映像。请再检测一遍你的安装盘。”
我听说要在DELPHI6里注册一下DLL文件才能使用,我比较疑惑的问题是:“为什么有时调用DLL文件中的一个函数可以有时不行又出现上面的出错信息。”
总之,我要如何操作和使用DLL文件在DELPHI6里。
代码:
library Delphi;
uses
SysUtils,
Classes;
function TestDll(i:integer;ii:integer):integer;stdcall;
var
C:integer;
begin
C:=i*ii;
Result:=C;
end;
exports
TestDll;
begin
end.
调用代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function TestDll(i:integer;ii:integer):integer;stdcall;
external ’Delphi.dll’;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Text:=IntToStr(TestDll(1,2));
end;
end.
只要调用就出现下面的信息:
"profect1.exe-损坏的图象 //信息框的标头
应用程序或DLL E:\DELPHIDLL\DELL.DLL为无效的WINDOWS映像。请再检测一遍你的安装盘。”
请各位程序员帮我解决一下这个问题,多谢!