怎样才能读取一个光盘的卷标?(50分)

  • 主题发起人 主题发起人 xao_hx
  • 开始时间 开始时间
X

xao_hx

Unregistered / Unconfirmed
GUEST, unregistred user!
如题,各位大侠帮忙!
 
用GetVolumnInformation函数,和读取硬盘的一样.下面是一个DEmo.<br>Demo中的label就是.<br><br>function TSysinfo.GetDiskInfo(strDrive : string) : boolean;<br>var<br>&nbsp; lpLabel : pChar;<br>&nbsp; LabelSize : cardinal;<br>&nbsp; SerialNum : cardinal;<br>&nbsp; MaxLength : cardinal;<br>&nbsp; lpFileName : pChar;<br>&nbsp; Filesize : cardinal;<br>&nbsp; FileFlag : cardinal;<br><br>&nbsp; FreeSpace,TotalSpace : int64;<br>&nbsp; str : string;<br>begin<br>&nbsp; result := true;<br>&nbsp; LabelSize := 255;<br>&nbsp; FileSize := 255;<br>&nbsp; GetMem(lpLabel,LabelSize);<br>&nbsp; GetMem(lpFileName,Filesize);<br>&nbsp; try<br>&nbsp; &nbsp; if GetVolumeInformation(PChar(strDrive),lpLabel,LabelSize,@SerialNum,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MaxLength,FileFlag,lpFileName,FileSize) then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; DiskInfo.DiskName := strDrive;<br>&nbsp; &nbsp; &nbsp; DiskInfo.DiskLabel := lpLabel;<br>&nbsp; &nbsp; &nbsp; DiskInfo.DiskFormat := lpFileName;<br>&nbsp; &nbsp; &nbsp; str := IntToHex(SerialNum,8);<br>&nbsp; &nbsp; &nbsp; DiskInfo.DiskSerialNum := Copy(str,1,4)+':'+Copy(str,5,4);<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; result := False;<br><br>&nbsp; case GetDriveType(PChar(DiskInfo.DiskName)) of<br>&nbsp; &nbsp; DRIVE_UNKNOWN : DiskInfo.DiskType := '未知驱动器';<br>&nbsp; &nbsp; DRIVE_NO_ROOT_DIR : DiskInfo.DiskType := '不是驱动器';<br>&nbsp; &nbsp; DRIVE_REMOVABLE : DiskInfo.DiskType := '软驱';<br>&nbsp; &nbsp; DRIVE_FIXED : &nbsp;DiskInfo.DiskType := '本地硬盘';<br>&nbsp; &nbsp; DRIVE_REMOTE : DiskInfo.DiskType := '网络硬盘';<br>&nbsp; &nbsp; DRIVE_CDROM : DiskInfo.DiskType := '光驱';<br>&nbsp; &nbsp; DRIVE_RAMDISK : DiskInfo.DiskType := '虚拟硬盘';<br>&nbsp; else DiskInfo.DiskType := '未知驱动器';<br>&nbsp; end;<br><br>&nbsp; if GetDiskFreeSpaceEx(PChar(DiskInfo.DiskName),FreeSpace,TotalSpace,nil) then<br>&nbsp; begin<br>&nbsp; &nbsp; DiskInfo.DiskTotalSpace := CaculateByte(TotalSpace);<br>&nbsp; &nbsp; DiskInfo.DiskFreeSpace := CaculateByte(FreeSpace);<br>&nbsp; &nbsp; DiskInfo.DiskUsageSpace := Trunc((TotalSpace - FreeSpace) / TotalSpace * 100);<br>&nbsp; end<br>&nbsp; else<br>&nbsp; &nbsp; result := false;<br>&nbsp; finally<br>&nbsp; &nbsp; FreeMem(lpLabel);<br>&nbsp; &nbsp; FreeMem(lpFileName);<br>&nbsp; end;<br>end;<br>
 
uses mmsystem,mplayer;<br>var:mp:tmediaplayer;msp:tmci_info_parms;<br>mediastring:array[0..255]of char;<br>ret:longint;<br>begin<br>&nbsp;mp:=tmediaplayer.create(nil);<br>mp.visible:=false;<br>mp.parent:=application.mainform;<br>mp.shareable:=true;<br>mp.devicetype:=dtcdaudio;<br>mp.filename:='d:';<br>mp.open;<br>application.processmessage;<br>fillchar(mediastring,sizeof(mediastring),#0);<br>fillchar(msp,sizeof(msp),#0);<br>msp.lpstrreturn:=@mediastring;<br>msp.dwretsize;<br>net:=mcisendcommand(mp.deviceid,mci_info,mci_info_media_identity,longint(@msp));<br>if ret&lt;&gt;0 then<br>begin<br>mcigeterrorstring(ret,@mediastring,sizeof(mediastring));<br>end<br>mp.close;<br>application.processmessage;<br>mp.free;<br>end;
 
try this one:<br><br><br>uses MMSystem, MPlayer; <br>&nbsp; <br>&nbsp; procedure TForm1.Button1Click(Sender: TObject); <br>&nbsp; var <br>&nbsp; &nbsp; mp : TMediaPlayer; <br>&nbsp; &nbsp; msp : TMCI_INFO_PARMS; <br>&nbsp; &nbsp; MediaString : array[0..255] of char; <br>&nbsp; &nbsp; ret : longint; <br>&nbsp; <br>&nbsp; begin <br>&nbsp; &nbsp; mp := TMediaPlayer.Create(nil); <br>&nbsp; &nbsp; mp.Visible := false; <br>&nbsp; &nbsp; mp.Parent := Application.MainForm; <br>&nbsp; &nbsp; mp.Shareable := true; <br>&nbsp; &nbsp; mp.DeviceType := dtCDAudio; <br>&nbsp; &nbsp; mp.FileName := 'D:'; <br>&nbsp; &nbsp; mp.Open; <br>&nbsp; &nbsp; Application.ProcessMessages; <br>&nbsp; &nbsp; FillChar(MediaString, sizeof(MediaString), #0); <br>&nbsp; &nbsp; FillChar(msp, sizeof(msp), #0); <br>&nbsp; &nbsp; msp.lpstrReturn := @MediaString; <br>&nbsp; &nbsp; msp.dwRetSize := 255; <br>&nbsp; &nbsp; ret := mciSendCommand(Mp.DeviceId, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MCI_INFO, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MCI_INFO_MEDIA_IDENTITY, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; longint(@msp)); <br>&nbsp; &nbsp; if Ret &lt;&gt; 0 then <br>&nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; MciGetErrorString(ret, @MediaString, sizeof(MediaString)); <br>&nbsp; &nbsp; &nbsp; Memo1.Lines.Add(StrPas(MediaString)); <br>&nbsp; &nbsp; end <br>&nbsp; &nbsp; else <br>&nbsp; &nbsp; &nbsp; Memo1.Lines.Add(StrPas(MediaString)); <br>&nbsp; &nbsp; mp.Close; <br>&nbsp; &nbsp; Application.ProcessMessages; <br>&nbsp; &nbsp; mp.free; <br>&nbsp; end; <br><br>
 
后退
顶部