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) 终于看完了~~~
http://www.discuz.net/static/image/common/sigline.gif
https://img.alicdn.com/imgextra/i4/871851027/TB2XlRhfdFopuFjSZFHXXbSlXXa_!!2-martrix_bbs.png 找了一圈了{:face (197):} 传送的可以,学习一下 在win10不能运行,郁闷,还是要找其他方法 在win10不能运行,郁闷,还是要找其他方法啊,谁会吗 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]