|
本帖最后由 foxfirefox 于 2019-11-8 13:24 编辑
//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");
}
这个是百度上搜来的一段代码。
楼主使用的的代码只是后面的一段。。。。
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");
} |
|