W
wsj1208
Unregistered / Unconfirmed
GUEST, unregistred user!
下面这个动态链接库程序调用返回时出错,请各位大侠出手相助,谢谢!
动态链接库程序如下:
library bhcomm;
uses
SysUtils,
Classes,
Windows;
{$R *.RES}
function GeneCode:integer;far;stdcall;export;
var
SerialNum : pdword;
a, b : dword;
Buffer : array [0..255] of char;
sdisk:string;
begin
//获得C盘序列号:
if GetVolumeInformation('c:/', Buffer, SizeOf(Buffer), SerialNum, a, b, nil, 0) then
sdisk := IntToStr(SerialNum^);
if sdisk='12345' then
result:=0
else
result:=1;
end;
exports
GeneCode;
end.
调用程序如下:
unit main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function GeneCode:integer;stdcall;external 'bhcomm.dll';
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
showmessage(inttostr(GeneCode));
end;
end.
动态链接库程序如下:
library bhcomm;
uses
SysUtils,
Classes,
Windows;
{$R *.RES}
function GeneCode:integer;far;stdcall;export;
var
SerialNum : pdword;
a, b : dword;
Buffer : array [0..255] of char;
sdisk:string;
begin
//获得C盘序列号:
if GetVolumeInformation('c:/', Buffer, SizeOf(Buffer), SerialNum, a, b, nil, 0) then
sdisk := IntToStr(SerialNum^);
if sdisk='12345' then
result:=0
else
result:=1;
end;
exports
GeneCode;
end.
调用程序如下:
unit main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function GeneCode:integer;stdcall;external 'bhcomm.dll';
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
showmessage(inttostr(GeneCode));
end;
end.