procedure TForm1.Button1Click(Sender: TObject);
var
  RootPath: array[0..20] of Char;     // holds the root directory name
  VolName: array[0..255] of Char;     // holds the volume name
  SerialNumber: DWORD;                // holds the serial number
  MaxCLength: DWORD;                  // holds the maximum file component length
  FileSysFlag: DWORD;                 // holds file system flags  FileSysName: array[0..255] of Char; // holds the name of the file system
begin
  {indicate information is to be retrieved from the C drive}
  RootPath := 'C:\';  {retrieve the volume information}
  GetVolumeInformation(RootPath, VolName, 255, @SerialNumber, MaxCLength,
     FileSysFlag, FileSysName, 255);  {display the information}
  Panel2.Caption := VolName;
  Panel3.Caption := IntToHex(SerialNumber,8);  Panel4.Caption := FileSysName;
end;

解决方案 »

  1.   

              检测光驱硬盘的序列
    注:如果返回值为'0000-0000',则未检测到。
    function GetHDSerialNumber(Drv : String): String;
    var
      VolumeSerialNumber : DWORD;
      MaximumComponentLength : DWORD;
      FileSystemFlags : DWORD;
    begin
      if Drv[Length(Drv)] =':' then Drv := Drv + '\';
      GetVolumeInformation(pChar(Drv),
                           nil,
                           0,
                           @VolumeSerialNumber,
                           MaximumComponentLength,
                           FileSystemFlags,
                           nil,
                           0);
      Result := IntToHex(HiWord(VolumeSerialNumber), 4) +
                '-' +
                IntToHex(LoWord(VolumeSerialNumber), 4);
    end;
    给个例子你吧!