无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站投放广告、加入VIP会员,请联系 微信:wuyouceo
查看: 5634|回复: 15
打印 上一主题 下一主题

Gpt/Fdd/Mbr硬盘格式判断小插件

  [复制链接]
1#
发表于 2022-5-29 00:45:09 | 显示全部楼层
本帖最后由 2012jiashanni 于 2022-5-29 00:47 编辑

点赞
回复

使用道具 举报

2#
发表于 2022-5-29 00:57:18 | 显示全部楼层
Func _GetDrivePartitionStyle($sDrive)
        Local $tDriveLayout = DllStructCreate('dword PartitionStyle;' & _
                        'dword PartitionCount;' & _
                        'byte union[40];' & _
                        'byte PartitionEntry[8192]')
        Local $hDrive = DllCall("kernel32.dll", "handle", "CreateFileW", _
                        "wstr", "\\.\" & $sDrive, _
                        "dword", 0, _
                        "dword", 0, _
                        "ptr", 0, _
                        "dword", 3, _ ; OPEN_EXISTING
                        "dword", 0, _
                        "ptr", 0)
        If @error Or $hDrive[0] = Ptr(-1) Then Return SetError(@error, @extended, 0) ; INVALID_HANDLE_VALUE
        DllCall("kernel32.dll", "int", "DeviceIoControl", _
                        "hwnd", $hDrive[0], _
                        "dword", 0x00070050, _
                        "ptr", 0, _
                        "dword", 0, _
                        "ptr", DllStructGetPtr($tDriveLayout), _
                        "dword", DllStructGetSize($tDriveLayout), _
                        "dword*", 0, _
                        "ptr", 0)
        DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hDrive[0])
        Switch DllStructGetData($tDriveLayout, "PartitionStyle")
                Case 0
                        Return "MBR"
                Case 1
                        Return "GPT"
                Case 2
                        Return "RAW"
                Case Else
                        Return "UNKNOWN"
        EndSwitch
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2025-11-13 09:28

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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