2

我对CD识别感兴趣。

我的问题:

是否有可以通过编程方式检索的序列号?

编辑(已解决):

  1. VB
  2. 德尔福
4

2 回答 2

2

在 VB 中尝试此代码

Private Declare Function GetVolumeInformation Lib "Kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
Private Sub Form_Load()
    Dim Serial As Long
    'Get the volume information
    GetVolumeInformation "d:\", vbNullString, 255, Serial, 0, 0, vbNullString, 255

    MsgBox Hex(Serial)
End Sub 

这应该作为您的概念证明。您可以将其调整为您选择的语言。

取自这里:VB 论坛

于 2012-02-27T08:04:38.307 回答
1

Windows.GetVolumeInformation 语法

  GetVolumeInformation(
    lpRootPathName: PChar; {the path to the root directory}
    lpVolumeNameBuffer: PChar; {the buffer receiving the volume name}
    nVolumeNameSize: DWORD; {the maximum size of the buffer}
    lpVolumeSerialNumber: PDWORD; {a pointer to the volume serial number}
    var lpMaximumComponentLength: DWORD; {maximum file component name}
    var lpFileSystemFlags: DWORD; {file system flags}
    lpFileSystemNameBuffer: PChar; {the buffer receiving the file system name}
    nFileSystemNameSize: DWORD {the maximum size of the file system name}
  ): BOOL; {returns TRUE or FALSE}

Delphi 端口(略微改编自Andrei G的帖子)

GetCDROMSerial 片段:

  function GetCDROMSerial(AVolName: Char ) : DWord;
  var
   Dummy1, Dummy2 : DWord;
  begin
   GetVolumeInformation(
     PChar( AVolName+':' ),
     nil,
     0,
     @Result,
     Dummy1,
     Dummy2,
     nil,
     0
     );
  end;

使用示例:

  ShowMessage(Format('%X', [GetCDROMSerial('F')]));
于 2012-02-27T09:37:58.560 回答