获得硬盘序列号,生成序列号,每次启动时验证一下Public Function getdiskid() As String
    Dim aa As Long
    Dim VolName As String
    Dim fsysName As String
    Dim path As String
    Dim VolSeri As Long, compress As Long
    Dim Sysflag As Long, Maxlen As Long
    VolName = String(255, 0)
    fsysName = String(255, 0)
    aa = GetVolumeInformation(path, VolName, 256, VolSeri, Maxlen, Sysflag, fsysName, 256)
    getdiskid = Hex(VolSeri)
End Function

解决方案 »

  1.   

    我在补充一下,上面没api声明
      

  2.   

    例程
    http://www.applevb.com/sourcecode/volser.zip
      

  3.   

    TBBT,这样生成的序号其实不是硬盘的物理序号而是卷序号,用GHOST是可以制造出同样号的。
    VB是没办法直接读取物理号的。
      

  4.   

    Public Function GenKey(Username As String) As String
    Dim TVal As Long
    Dim i As Integer            'Variable Declaration
    Dim TText As String
    Dim TString As String
        TString = "" 'Reset the variable
        pb.Max = Len(Username) 'Set the scroll bars MAX property to the length of the Username
        Me.Caption = Me.Caption & " [Building Key...]" 'Change the caption of the window while generating
        For i = 1 To Len(Username) ' Start the loop using the length of the username
            pb.Value = i 'Show the status of the generation
            TVal = Asc(Mid(Username, i, 1)) + 2 'Converts the next letter of username to it's ASCII value, then add's 2
            TVal = TVal + Fix((TVal * (16 + Len(Username)))) 'This adds the last result with 16 * the length of the username
            TVal = TVal + Len(Username) 'It adds to the last result the length of the Username
            TString = TString & Trim(StrReverse(Str(TVal))) 'This reverses the last result and appends it to the last result in TString
        Next i 'Continue getting the next letter in Username
        
        TText = TString 'This puts the generated key into TText
        
       If Len(TText) >= 8 Then 'This tests to see if the length of the key is 8 or greater
            Mid(TText, 4, 1) = "-" 'If so then place a hypen in the key
            Mid(TText, 12, 1) = "-" 'Place another hypen in the key
       End If
       
        TText = Left(TText, 16) 'This trims the key down making it look nice :o)
        Me.Caption = "Key Master by Chazter" 'This returns the caption to it's former state
        GenKey = TText 'This makes the function equal to the generated key
    End Function
      

  5.   

    我见过一个用DDK写的直接读取硬盘ROM的程序,而且硬版的ROM编号几乎是不可能重复的。
      

  6.   

    to CityHost(市长) 
    你可以找到吗哪DDK的例程吗?
      

  7.   

    是啊!那里有直接读硬盘ROM的程序?
      

  8.   

    是从国外的一个程序里用DDK的反汇编功能解出的源代码,我现在要找一找。