H
hg605
Unregistered / Unconfirmed
GUEST, unregistred user!
用下列代码得出的光盘序号在win98和win2000中的结果不同,如何得出相同的光盘序号
代码如下
procedure TForm1.Button1Click(Sender: TObject);
var
// systeminfo: SYSTEM_INFO;
memory: MEMORYSTATUS;
// sector,byte,cluster,free: DWORD;
// freespace,totalspace: longint;
CDtype: UINT;
name: CHAR;
drvname: string;
volname,filesysname: PCHAR;
sno,maxl,fileflag: DWORD;
begin
//检测CD-ROM,是否有光盘
GetMem(volname, 255);
GetMem(filesysname, 100);
for name :='C' to 'Z' do
//循环检测A~Z
begin
drvname := name + ':';
CDtype := GetDriveType(PCHAR(@drvname[1]));
//获得磁盘类型
if (CDtype = DRIVE_CDROM) then
begin
Memo1.Lines.Add('您的光驱盘符为[' + drvname + ']');
volname^ := Chr(0);
filesysname^ := Chr(0);
if ( not (GetVolumeInformation(PCHAR(@drvname[1]), volname, 250, LPDWORD(@sno), LPDWORD(@maxl)^, LPDWORD(@fileflag)^, filesysname,100))) then
Memo1.Lines.Add(drvname + '驱中没有发现光盘') //如果返回值为假
else
//如果返回值为真
begin
Memo1.Lines.Add (drvname + '驱中光盘卷标为: [' + String(volname) + ']');
Memo1.Lines.Add (drvname + '驱中光盘序号为: [' + inttostr(sno) + ']');
end;
end;
end;
FreeMem(volname);
FreeMem(filesysname)
end;
代码如下
procedure TForm1.Button1Click(Sender: TObject);
var
// systeminfo: SYSTEM_INFO;
memory: MEMORYSTATUS;
// sector,byte,cluster,free: DWORD;
// freespace,totalspace: longint;
CDtype: UINT;
name: CHAR;
drvname: string;
volname,filesysname: PCHAR;
sno,maxl,fileflag: DWORD;
begin
//检测CD-ROM,是否有光盘
GetMem(volname, 255);
GetMem(filesysname, 100);
for name :='C' to 'Z' do
//循环检测A~Z
begin
drvname := name + ':';
CDtype := GetDriveType(PCHAR(@drvname[1]));
//获得磁盘类型
if (CDtype = DRIVE_CDROM) then
begin
Memo1.Lines.Add('您的光驱盘符为[' + drvname + ']');
volname^ := Chr(0);
filesysname^ := Chr(0);
if ( not (GetVolumeInformation(PCHAR(@drvname[1]), volname, 250, LPDWORD(@sno), LPDWORD(@maxl)^, LPDWORD(@fileflag)^, filesysname,100))) then
Memo1.Lines.Add(drvname + '驱中没有发现光盘') //如果返回值为假
else
//如果返回值为真
begin
Memo1.Lines.Add (drvname + '驱中光盘卷标为: [' + String(volname) + ']');
Memo1.Lines.Add (drvname + '驱中光盘序号为: [' + inttostr(sno) + ']');
end;
end;
end;
FreeMem(volname);
FreeMem(filesysname)
end;