找回密码  加入

AUTOIT CN

搜索
12
返回列表 发新帖
楼主: lllangxx

[求购] 取硬盘序列号

[复制链接]
发表于 2016-8-17 15:39:55 | 显示全部楼层
修改卷序列号:
  1. #include <include\SetupApi.au3>

  2. Const $IOCTL_LOCK_VOLUME = 0x90018
  3. Const $IOCTL_UNLOCK_VOLUME = 0x9001C
  4. Const $tagDRIVE_PER_SECTOR_DATA = "ubyte SectorData[512]"

  5. Local $hDrive, $iAccessMask, $pBuffer, $pSerial
  6. Local $tBuffer, $tSerial, $sDrive = "C:", $bNewSerial = 0x11111111

  7. $iAccessMask = bitOR($GENERIC_READ, $GENERIC_WRITE)
  8. $pBuffer = _CM_Heap_Alloc(512)

  9. Switch DriveGetFileSystem($sDrive)
  10. Case "NTFS"
  11.         $pSerial = $pBuffer + 72
  12. Case "FAT32"
  13.         $pSerial = $pBuffer + 67
  14. Case Else
  15.         _CM_Heap_Free($pBuffer)
  16.         Msgbox(48, "Error!", $sDrive & " not support.")
  17.         exit
  18. EndSwitch

  19. $hDrive = _CM_Create_File("\\." & $sDrive, $iAccessMask, 3, 0, 3, 0)
  20. _CM_Device_IO_Control($hDrive, $IOCTL_LOCK_VOLUME, 0, 0, 0, 0)
  21. _CM_Read_Device($hDrive, $pBuffer, 512)
  22. _CM_Device_IO_Control($hDrive, $IOCTL_UNLOCK_VOLUME, 0, 0, 0, 0)
  23. _CM_Close_Handle($hDrive)

  24. $tBuffer = DllStructCreate($tagDRIVE_PER_SECTOR_DATA, $pBuffer)

  25. $tSerial = DllStructCreate("hWnd Serial", $pSerial)
  26. DllStructSetData($tSerial, "Serial", $bNewSerial)

  27. $hDrive = _CM_Create_File("\\." & $sDrive, $iAccessMask, 3, 0, 3, 0)
  28. _CM_Device_IO_Control($hDrive, $IOCTL_LOCK_VOLUME, 0, 0, 0, 0)
  29. _CM_Write_Device($hDrive, $pBuffer, 512)
  30. _CM_Device_IO_Control($hDrive, $IOCTL_UNLOCK_VOLUME, 0, 0, 0, 0)
  31. _CM_Close_Handle($hDrive)

  32. Msgbox(64, "", "Done!")
  33. If (DriveGetFileSystem($sDrive) = "NTFS") Then
  34.         Msgbox(48, "", "A system reboot is required to update the serial number.")
  35. EndIf
  36. Opt("TrayIconHide", 1)
  37. ProcessClose(@AutoItPid)
复制代码
回复

使用道具 举报

发表于 2017-8-13 22:35:00 | 显示全部楼层
终于看完了~~~












回复

使用道具 举报

发表于 2017-9-11 21:42:16 | 显示全部楼层
找了一圈了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|小黑屋|手机版|AUTOIT CN ( 鲁ICP备15028933号-3 )谷歌 百度

GMT+8, 2018-11-14 03:57 , Processed in 0.077386 second(s), 10 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表