the following code returns #False on my PC with BIOS, as expected.
I would appreciate it, if some of you would test the code on your systems.
Especially interesting for me is to know, whether the function actually returns #True on computers with UEFI.
I'd also be grateful for suggestions for improvement, if necessary.
Thanks in advance!
Code: Select all
EnableExplicit
Import "kernel32.lib"
   GetFirmwareEnvironmentVariableA (name.p-ascii, guid.p-ascii, *buffer, nSize.l)
EndImport
Procedure.i UsesUEFI()
   ; out: #True  if the used system firmware is UEFI,
   ;      #False if the used system firmware is BIOS.
   ;
   ; <https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getfirmwareenvironmentvariablea>, 2019-09-24
   ; tested with PB 5.71 (x86 and x64) under Windows 10 Pro Version 1903 with BIOS
   Protected *buffer, error.i, nSize.l=1000
   
   *buffer = AllocateMemory(nSize)
   GetFirmwareEnvironmentVariableA("", "{00000000-0000-0000-0000-000000000000}", *buffer, nSize)
   error = GetLastError_()
   FreeMemory(*buffer)
   
   ProcedureReturn Bool(error <> #ERROR_INVALID_FUNCTION)
EndProcedure
;-- Demo
Debug UsesUEFI()






