找回密码
 加入
搜索
楼主: lllangxx

[求购] 取硬盘序列号

 火... [复制链接]
发表于 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[512]"

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 | 显示全部楼层
终于看完了~~~












发表于 2017-9-11 21:42:16 | 显示全部楼层
找了一圈了
发表于 2021-5-3 00:17:11 | 显示全部楼层
传送的可以,学习一下
发表于 2021-5-17 11:15:33 | 显示全部楼层
在win10不能运行,郁闷,还是要找其他方法
发表于 2021-5-17 11:19:46 | 显示全部楼层
在win10不能运行,郁闷,还是要找其他方法啊,谁会吗
发表于 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
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-19 12:48 , Processed in 0.077050 second(s), 14 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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