Get Hard Drive Serial Number in VC++
-
Can anyone tell me how to obtain the actual hard drive serial number from a VC++ application? Thanks
See DiskId32. A Freeware utility, along with VC++ source code!:cool: ARSALAN MALIK
-
Can anyone tell me how to obtain the actual hard drive serial number from a VC++ application? Thanks
I hope this helps...
CString CDlgReg::GetDriveID()
{
char dbits[100],drive[100];
int i;
i=0;
DWORD d=GetLogicalDriveStrings(100, dbits);
strncpy(drive,dbits+i,4);
for (int nDrives = 0; nDrives < 26; nDrives ++)
{
if(GetDriveType(drive)==DRIVE_FIXED)
break;
i+=4;
strncpy(drive,dbits+i,4);
}
char vol[40];
DWORD mf;
DWORD sf,sno;
GetVolumeInformation(drive,vol,sizeof(vol),&sno,&mf,&sf,NULL,NULL);m\_dDriveID=sno; CString s; s.Format("%08X",sno); return s;
}
-
I hope this helps...
CString CDlgReg::GetDriveID()
{
char dbits[100],drive[100];
int i;
i=0;
DWORD d=GetLogicalDriveStrings(100, dbits);
strncpy(drive,dbits+i,4);
for (int nDrives = 0; nDrives < 26; nDrives ++)
{
if(GetDriveType(drive)==DRIVE_FIXED)
break;
i+=4;
strncpy(drive,dbits+i,4);
}
char vol[40];
DWORD mf;
DWORD sf,sno;
GetVolumeInformation(drive,vol,sizeof(vol),&sno,&mf,&sf,NULL,NULL);m\_dDriveID=sno; CString s; s.Format("%08X",sno); return s;
}
GetVolumeInformation
returns logical serial number of a volume, not the serial number of hard drive!;P ARSALAN MALIK -
Can anyone tell me how to obtain the actual hard drive serial number from a VC++ application? Thanks
Win32_DiskDrive is a WMI class which can give u this serial no. Imagine that you are creating a fabric of human destiny with the object of making men happy in the end, giving them peace and rest at last, but that it was essential and inevitable to torture to death only one tiny creature..and to found that edifice on its unavenged tears, would you consent to be the architect on those conditions? Tell me, and tell me the truth! -Fyodor Dostoevsky, The Brothers Karamazov
-
I hope this helps...
CString CDlgReg::GetDriveID()
{
char dbits[100],drive[100];
int i;
i=0;
DWORD d=GetLogicalDriveStrings(100, dbits);
strncpy(drive,dbits+i,4);
for (int nDrives = 0; nDrives < 26; nDrives ++)
{
if(GetDriveType(drive)==DRIVE_FIXED)
break;
i+=4;
strncpy(drive,dbits+i,4);
}
char vol[40];
DWORD mf;
DWORD sf,sno;
GetVolumeInformation(drive,vol,sizeof(vol),&sno,&mf,&sf,NULL,NULL);m\_dDriveID=sno; CString s; s.Format("%08X",sno); return s;
}
-
See DiskId32. A Freeware utility, along with VC++ source code!:cool: ARSALAN MALIK