|
au3代码
- #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')
- Else
- MsgBox(0,'','UEFI Boot Mode')
- EndIf
复制代码
c++代码
- //百度很多资料都没有找到, 终于在谷歌上找到很多有用的资料了, 最后在微软的网站找到最有用的资料了.
- //判断流程可以这样:
- //1, 支持efi引导的//只有win7及以上, 所以xp, 03系统就只能够bios引导
- //2, win7,8,8.1,10等系统, 可以用下面的代码, 本质上就是GetFirmwareEnvironmentVariableA, 或者GetFirmwareType这两个api的调用
-
- #include <Windows.h>
- #include <Winbase.h> //GetFirmwareEnvironmentVariableA 和 GetFirmwareType的头文件
- #include <iostream>
- using namespace std;
- void main()
- {
- //For Windows 8/Server 2012 and above可用
- /*
- typedef enum _FIRMWARE_TYPE {
- FirmwareTypeUnknown = 0,
- FirmwareTypeBios = 1,
- FirmwareTypeUefi = 2,
- FirmwareTypeMax = 3
- } FIRMWARE_TYPE, *PFIRMWARE_TYPE;
- */
- FIRMWARE_TYPE a;
- GetFirmwareType(&a);
- switch (a)
- {
- case FirmwareTypeUnknown:
- cout << "不知名引导" << endl; break;
- case FirmwareTypeBios:
- cout << "Bios引导" << endl; break;
- case FirmwareTypeUefi:
- cout << "Uefi引导" << endl; break;
- case FirmwareTypeMax:
- cout << "Not implemented" << endl; break;
- }
-
- //Windows 7/Server 2008R2 and above可用
- GetFirmwareEnvironmentVariableA("", "{00000000-0000-0000-0000-000000000000}", NULL, 0);
- if (GetLastError() == ERROR_INVALID_FUNCTION)
- //API not supported; this is a legacy BIOS
- cout << "Bios引导" << endl;
- else
- //API error (expected) but call is supported.This is UEFI.
- cout << "Uefi引导" << endl;
-
- system("pause");
- }
-
复制代码 |
|