CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2001
    Posts
    1

    Reading a Unique System ID

    I have a requirement to read/get a a unique ID from a computer that some software I wrote will run on. I figured either getting the Windows OEM#, CD Key, or the Processor/chip number are good methods but I'm not sure where to start on this one.

    Any help/code example would be great! I'm fairly new to VB client programming. Thanks in advance for you help.

    Rob


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Reading a Unique System ID

    You can read the hard drive serial number

    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 Long
    Dim SerialNum As Long
    Dim Res As Long
    Dim strTmp As String
    Dim strTmp2 As String
    strTmp = String$(255, Chr$(0))
    strTmp2 = String$(255, Chr$(0))
    Res = GetVolumeInformation(strDrive, strTmp, _
    Len(strTmp), SerialNum, 0, 0, strTmp2, Len(strTmp2))
    GetSerialNumber = SerialNum
    End Function





    Private Sub Command1_Click()
    Me.Caption = GetSerialNumber("C:\")
    End Sub




    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured