N
net77
Unregistered / Unconfirmed
GUEST, unregistred user!
dll源码:
library ProjectDll;
uses
SysUtils,
Classes;
{$R *.res}
function nn(n:integer):integer;stdcall;
var i:integer;
begin
result:=1;
for i:=1 to n do result:=result*i;
end;
exports
nn;
begin
end.
调用程序源码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function nn(n:integer):integer;stdcall;
external 'Projectdll.dll';
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text:=inttostr(nn(strtoint(edit1.Text)));
end;
end.
为什么F9运行时不能运行,马上回到编辑状态,不能出现正常的运行后的Form。
我已经把dll文件拷到这个调用程序的文件夹下了。
我用的delphi7
library ProjectDll;
uses
SysUtils,
Classes;
{$R *.res}
function nn(n:integer):integer;stdcall;
var i:integer;
begin
result:=1;
for i:=1 to n do result:=result*i;
end;
exports
nn;
begin
end.
调用程序源码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function nn(n:integer):integer;stdcall;
external 'Projectdll.dll';
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text:=inttostr(nn(strtoint(edit1.Text)));
end;
end.
为什么F9运行时不能运行,马上回到编辑状态,不能出现正常的运行后的Form。
我已经把dll文件拷到这个调用程序的文件夹下了。
我用的delphi7