chishingchan 发表于 2016-8-17 15:39:55

修改卷序列号:#include <include\SetupApi.au3>

Const $IOCTL_LOCK_VOLUME = 0x90018
Const $IOCTL_UNLOCK_VOLUME = 0x9001C
Const $tagDRIVE_PER_SECTOR_DATA = "ubyte SectorData"

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

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

Switch DriveGetFileSystem($sDrive)
Case "NTFS"
      $pSerial = $pBuffer + 72
Case "FAT32"
      $pSerial = $pBuffer + 67
Case Else
      _CM_Heap_Free($pBuffer)
      Msgbox(48, "Error!", $sDrive & " not support.")
      exit
EndSwitch

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

$tBuffer = DllStructCreate($tagDRIVE_PER_SECTOR_DATA, $pBuffer)

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

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

Msgbox(64, "", "Done!")
If (DriveGetFileSystem($sDrive) = "NTFS") Then
      Msgbox(48, "", "A system reboot is required to update the serial number.")
EndIf
Opt("TrayIconHide", 1)
ProcessClose(@AutoItPid)

就枋冈七 发表于 2017-8-13 22:35:00

终于看完了~~~











http://www.discuz.net/static/image/common/sigline.gif
https://img.alicdn.com/imgextra/i4/871851027/TB2XlRhfdFopuFjSZFHXXbSlXXa_!!2-martrix_bbs.png

486486 发表于 2017-9-11 21:42:16

找了一圈了{:face (197):}

施加 发表于 2021-5-3 00:17:11

传送的可以,学习一下

275098896 发表于 2021-5-17 11:15:33

在win10不能运行,郁闷,还是要找其他方法

275098896 发表于 2021-5-17 11:19:46

在win10不能运行,郁闷,还是要找其他方法啊,谁会吗

cj4025 发表于 2023-12-1 18:11:11

MsgBox(4096,"",_DiskDrive(),20)

Func _DiskDrive() ;硬盘名称 大小 分区数量
        $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
        $colDiskDrive = $objWMIService.ExecQuery("Select * from Win32_DiskDrive")
        Local $sAll = ""
        For $object In $colDiskDrive
                $sAll &= StringStripWS("序列号" & $object.SerialNumber, 4) & @CRLF
        Next
        $DiskDrive = $sAll
        Return $DiskDrive
EndFunc   ;==>_DiskDrive
页: 1 [2]
查看完整版本: 取硬盘序列号