如何得到机器的主硬盘序列号?有例程没?
解决方案 »
- 我想把一个单文档应用程序切分为基于CListView和CFormView应该怎么实现??
- 关于邮槽,大家帮忙哦。
- 我想提高CListCtrl的项高。我设置了字体还是没有拉动item的高度。
- 程序运行后出现Query the registry to get manually configured process list.
- 建立vc学习开发团队,欢迎大三大四学生参加
- 请问关于在NT/2000中交互式的登陆支持是由WinLogon调用GINA DLL的编程的问题!
- 急救,VC用Ado连接Access数据库,Execute执行查询语句时,带“like”语法的问题??
- 一个莫名奇妙的问题--没有初始化??
- 如何通过VC创建“宽带连接”的桌面快捷方式? 求教
- 请教各位高手,谢谢
- 如何在ie工具栏上添加自定义的图标按钮,类似雅虎工具条
- 为什么我的gethostname有问题?
#define DFP_GET_VERSION 0x00074080
int ReadPhysicalDriveInNT (DWORD diskdata[256])
{
int done = FALSE;
int drive = 0; HANDLE hPhysicalDriveIOCTL = 0; // Try to get a handle to PhysicalDrive IOCTL, report failure
// and exit if can't. char driveName [256];
sprintf (driveName, "\\\\.\\PhysicalDrive%d", drive);
// Windows NT, Windows 2000, must have admin rights
hPhysicalDriveIOCTL = CreateFile (driveName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, 0, NULL);
// if (hPhysicalDriveIOCTL == INVALID_HANDLE_VALUE)
// printf ("Unable to open physical drive %d, error code: 0x%lX\n",
// drive, GetLastError ()); if (hPhysicalDriveIOCTL != INVALID_HANDLE_VALUE)
{
GETVERSIONOUTPARAMS VersionParams;
DWORD cbBytesReturned = 0; // Get the version, etc of PhysicalDrive IOCTL
memset ((void*) &VersionParams, 0, sizeof(VersionParams)); if ( ! DeviceIoControl (hPhysicalDriveIOCTL, DFP_GET_VERSION,
NULL,
0,
&VersionParams,
sizeof(VersionParams),
&cbBytesReturned, NULL) )
{
// printf ("DFP_GET_VERSION failed for drive %d\n", i);
// continue;
} // If there is a IDE device at number "i" issue commands
// to the device
if (VersionParams.bIDEDeviceMap > 0)
{
BYTE bIDCmd = 0; // IDE or ATAPI IDENTIFY cmd
SENDCMDINPARAMS scip;
//SENDCMDOUTPARAMS OutCmd; // Now, get the ID sector for all IDE devices in the system.
// If the device is ATAPI use the IDE_ATAPI_IDENTIFY command,
// otherwise use the IDE_ATA_IDENTIFY command
bIDCmd = (VersionParams.bIDEDeviceMap >> drive & 0x10) ? \
IDE_ATAPI_IDENTIFY : IDE_ATA_IDENTIFY; memset (&scip, 0, sizeof(scip));
memset (IdOutCmd, 0, sizeof(IdOutCmd)); if ( DoIDENTIFY (hPhysicalDriveIOCTL,
&scip,
(PSENDCMDOUTPARAMS)&IdOutCmd,
(BYTE) bIDCmd,
(BYTE) drive,
&cbBytesReturned))
{
int ijk = 0;
USHORT *pIdSector = (USHORT *)
((PSENDCMDOUTPARAMS) IdOutCmd) -> bBuffer; for (ijk = 0; ijk < 256; ijk++)
diskdata [ijk] = pIdSector [ijk]; done = TRUE;
} CloseHandle (hPhysicalDriveIOCTL);
}
} return done;
}或用GetVolumeInformation