K
keven
Unregistered / Unconfirmed
GUEST, unregistred user!
前几天,我写了一个获取光盘序列号的DLL,编译时没问题,但调用(静态、动态
都试过)时发生"Invalid Pointer Operation"错误!源程序如下:
library serial;
uses
base in 'base.pas';
{$R *.RES}
Exports GetCDROMVolume,GetDiskSerialNo;
begin
end.
unit base;
interface
uses
Sysutils,Classes,windows;
function GetDiskSerialNo(Drv:String):String;stdcall;
function GetCDROMVolume():String;stdcall;
implementation
{-----------获取序列号----------}
function GetDiskSerialNo(Drv:string):String;stdcall;
var
VolumeSerialNumberWORD;
MaximumComponentLengthWORD;
FileSystemFlagsWORD;
begin
GetVolumeInformation(Pchar(Drv),
nil,
0,
@VolumeSerialNumber,
MaximumComponentLength,
FileSystemFlags,
nil,
0);
Result:=IntToHex(HiWord(VolumeSerialNumber),4)+
'-'+
IntToHex(LoWord(VolumeSerialNumber),4);
end
{----------获取光驱的盘符----------}
function GetCDROMVolume():string;stdcall;
Var
Driver:string;
i:integer;
begin
i:=0;
Driver:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
repeat
Inc(i);
Until GetDriveType(Pchar(Driver+':/'))=DRIVE_CDROM;
Result:=driver+':/';
end;
end.
我怀疑是在DLL中调用API函数是发生的,各位有什么建议或其他的解决办法
(必须是DLL),请多多指教。
都试过)时发生"Invalid Pointer Operation"错误!源程序如下:
library serial;
uses
base in 'base.pas';
{$R *.RES}
Exports GetCDROMVolume,GetDiskSerialNo;
begin
end.
unit base;
interface
uses
Sysutils,Classes,windows;
function GetDiskSerialNo(Drv:String):String;stdcall;
function GetCDROMVolume():String;stdcall;
implementation
{-----------获取序列号----------}
function GetDiskSerialNo(Drv:string):String;stdcall;
var
VolumeSerialNumberWORD;
MaximumComponentLengthWORD;
FileSystemFlagsWORD;
begin
GetVolumeInformation(Pchar(Drv),
nil,
0,
@VolumeSerialNumber,
MaximumComponentLength,
FileSystemFlags,
nil,
0);
Result:=IntToHex(HiWord(VolumeSerialNumber),4)+
'-'+
IntToHex(LoWord(VolumeSerialNumber),4);
end
{----------获取光驱的盘符----------}
function GetCDROMVolume():string;stdcall;
Var
Driver:string;
i:integer;
begin
i:=0;
Driver:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
repeat
Inc(i);
Until GetDriveType(Pchar(Driver+':/'))=DRIVE_CDROM;
Result:=driver+':/';
end;
end.
我怀疑是在DLL中调用API函数是发生的,各位有什么建议或其他的解决办法
(必须是DLL),请多多指教。