怎么样在VB里得到当前盘c:的序列号因为,每个硬盘里格式化一次,序列号变换一次,几乎没有重复的怎么样才可以得到呢?

解决方案 »

  1.   

    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, VName As String, FSName As String
        'Create buffers
        VName = String$(255, Chr$(0))
        FSName = String$(255, Chr$(0))
        'Get the volume information
        GetVolumeInformation "C:\", VName, 255, Serial, 0, 0, FSName, 255
        'Strip the extra chr$(0)'s
        VName = Left$(VName, InStr(1, VName, Chr$(0)) - 1)
        FSName = Left$(FSName, InStr(1, FSName, Chr$(0)) - 1)
        MsgBox "The Volume name of C:\ is '" + VName + "', the File system name of C:\ is '" + FSName + "' and the serial number of C:\ is '" + Trim(Str$(Serial)) + "'", vbInformation + vbOKOnly, App.Title
    End Sub
      

  2.   

    硬盘序列号
    http://vip.6to23.com/NowCan1/tech/vb_hd_info.htm
    http://vip.6to23.com/NowCan1/code/hd_info.zip
    www.jiaxinda.com/dont_delete/98及2K取硬盘id号_类.exe
      

  3.   

    '把以下代码加入模块中,直接调用GetSerial()即可得到相应序列号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 LongPublic Function GetSerial() As String
    Dim rel As LongDim VolName As String      '磁盘名称
    Dim fsysName As String     '磁盘格式
    Dim VolSerial As Long      '磁盘序列号
    Dim Sysflag As Long
    Dim Maxlen As LongVolName = String(256, 0)
    fsysName = String(256, 0)rel = GetVolumeInformation("c:\", VolName, 256, VolSerial, Maxlen, Sysflag, fsysName, 256)
    GetSerial = Hex(VolSerial)End Function
      

  4.   

    Option ExplicitPrivate Sub Form_Load()
    '使用fso对象
    Dim fso As filesystemobject
    Dim drv As Drive
    Dim infostr As StringSet fso = New filesystemobject
    Set drv = fso.getdrive(fso.getdrivename("c:"))infostr = "driver" & UCase("c:") & vbCrLf
    infostr = infostr & "序列号:" & drv.serialnumber & vbCrLf
    MsgBox infostr
    End Sub
      

  5.   

    Public 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
    Global GetVal As Long
    Global GetVal2 As Long
    Private Sub Form_Load()
    Dim TempStr1 As String * 256Dim TempStr2 As String * 256Dim TempLon1 As LongDim TempLon2 As LongCall GetVolumeInformation("C:\", TempStr1, 256, GetVal, TempLon1, TempLon2, TempStr2, 256)
    Text1.Text = GetVal  '提取本机C盘的序列号至文本框一
    End Sub
      

  6.   

    我接着此题问一下,怎么修改呀?
    注:用编码的方式(vb,vc,asm等等)
      

  7.   

    Private Declare Function GetVolumeInformation Lib _
    "kernel32.dll" Alias "GetVolumeInformationA" (ByVal _
    lpRootPathName As String, ByVal lpVolumeNameBuffer As _
    String, ByVal nVolumeNameSize As Integer, _
    lpVolumeSerialNumber As Long, lpMaximumComponentLength _
    As Long, lpFileSystemFlags As Long, ByVal _
    lpFileSystemNameBuffer As String, ByVal _
    nFileSystemNameSize As Long) As Long '代码如下: Function GetSerialNumber(strDrive As String) As LongDim SerialNum As LongDim Res As LongDim Temp1 As StringDim Temp2 As StringTemp1 = String$(255, Chr$(0))Temp2 = String$(255, Chr$(0))Res = GetVolumeInformation(strDrive, Temp1, _
    Len(Temp1), SerialNum, 0, 0, Temp2, Len(Temp2))GetSerialNumber = SerialNumEnd Function
      

  8.   

    Private Sub Command1_Click()
     Label1.Caption = GetSerialNumber(Text1.Text + ":\") 
    End SubPrivate Sub form_load()
    '使用该函数: '它将告诉磁盘序号。End Sub