获取磁盘序列号GetVolumeInformation

// GetVolume.cpp : Defines the entry point for the console application.
//


#include "stdafx.h"
#include
#include


void CVolSerialNumDlg()
{
    TCHAR volumeName[MAX_PATH + 1] = { 0 };
    TCHAR fileSystemName[MAX_PATH + 1] = { 0 };
    DWORD serialNumber = 0;
    DWORD maxComponentLen = 0;
    DWORD fileSystemFlags = 0;
    if (GetVolumeInformation(
        _T("C:\\"),
        volumeName,
        ARRAYSIZE(volumeName),
        &serialNumber,
        &maxComponentLen,
        &fileSystemFlags,
        fileSystemName,
        ARRAYSIZE(fileSystemName)))
    {
        _tprintf(_T("Volume Name: %s\n"), volumeName);
        _tprintf(_T("Serial Number: %lu\n"), serialNumber);
        _tprintf(_T("File System Name: %s\n"), fileSystemName);
        _tprintf(_T("Max Component Length: %lu\n"), maxComponentLen);
        _tprintf(_T("\n"));
    } 
}


int _tmain(int argc, _TCHAR* argv[])
{
   
    CVolSerialNumDlg();
    
    return 0;
}


你可能感兴趣的:(VC)