CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 1999
    Location
    Gothenburg, Sweden
    Posts
    11

    Hard drive serial number

    Hi,

    Does anyone know how to read/get a hard drive's serial number? (win95/98/NT4)

    Thanks!


    Peter Segerdahl

  2. #2
    Join Date
    Apr 1999
    Posts
    72

    Re: Hard drive serial number

    I went through a lot of posting to get the following code. But it does work:


    char RootPathName[MAX_PATH];
    char VolumeNameBuffer[MAX_PATH];
    DWORD VolumeNameSize=MAX_PATH;
    DWORD VolumeSerialNumber=0;
    DWORD MaximumComponentLength=0;
    DWORD FileSystemFlags=0;
    char FileSystemNameBuffer[MAX_PATH];
    DWORD FileSystemNameSize=MAX_PATH;
    strcpy(RootPathName,"C:\\");

    GetVolumeInformation(RootPathName, VolumeNameBuffer, VolumeNameSize, &VolumeSerialNumber, &MaximumComponentLength, &FileSystemFlags, FileSystemNameBuffer, FileSystemNameSize);

    CString tmpstr;

    tmpstr.Format("%x",VolumeSerialNumber);
    m_Reg.SetWindowText( tmpstr );



    I used it for a registration code on one of my programs.

    Thanks!
    Nathan Strandberg


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