[求助]AU3如何判断磁盘是GPT还是MBR
#include <WinAPI.au3>Global Const $ERROR_INVALID_FUNCTION = 0x1
DllCall("Kernel32.dll", "dword", "GetFirmwareEnvironmentVariableW", "wstr", "", "wstr", "{00000000-0000-0000-0000-000000000000}", "wstr", Null, "dword", 0)
If _WinAPI_GetLastError() = $ERROR_INVALID_FUNCTION Then
MsgBox(0, '', 'Legacy BIOS - MBR')
Else
MsgBox(0, '', 'UEFI - GPT')
EndIf
在网上找了这个,好像不起作用的。
大家有没有更加好的方法?
#include <Constants.au3>
If IsUEFI() Then
MsgBox(4096, "", "UEFI")
Else
MsgBox(4096, "", "传统")
EndIf
Func IsUEFI()
Local $output = ""
$output = Run(@ComSpec & " /c " & "bcdedit /enum | findstr /c:{fwbootmgr}", "", @SW_HIDE, $STDOUT_CHILD)
$output = StringStripWS($output, 7)
Return $output <> ""
EndFunc ;==>IsUEFI
以前收藏的,看看能行不 h111666b 发表于 2025-12-1 10:33
#include
不行哦,我的磁盘是传统模式,识别是UEFI 了。 我也是用的是楼主这个,应该可以的。 Global Const $error_invalid_function = 1
DllCall("Kernel32.dll", "dword", "GetFirmwareEnvironmentVariableW", "wstr", "", "wstr", "{00000000-0000-0000-0000-000000000000}", "wstr", Null, "dword", 0)
If _WinAPI_GetLastError() = $error_invalid_function Then
$PartitionTable = "MBR"
Else
$PartitionTable = "GPT"
EndIf
MsgBox(0,"磁盘分区表",$PartitionTable)
Func _WinAPI_GetLastError(Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
Local $aresult = DllCall("kernel32.dll", "dword", "GetLastError")
Return SetError($_icurrenterror, $_icurrentextended, $aresult)
EndFunc 这个代码是判断主板启动方式的,和磁盘没有关系。磁盘的话,需要读取磁盘分区表结构,记得论坛有代码,搜搜看。
页:
[1]