Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
System Services
System Information
 GetFirmwareEnvironmentVariable func...
GetFirmwareEnvironmentVariable function

Applies to: desktop apps only

Retrieves the value of the specified firmware environment variable.

Syntax

DWORD WINAPI GetFirmwareEnvironmentVariable(
  __in   LPCTSTR lpName,
  __in   LPCTSTR lpGuid,
  __out  PVOID pBuffer,
  __in   DWORD nSize
);

Parameters

lpName [in]

The name of the firmware environment variable. The pointer must not be NULL.

lpGuid [in]

The GUID that represents the namespace of the firmware environment variable. The GUID must be a string in the format "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" where 'x' represents a hexadecimal value.

pBuffer [out]

A pointer to a buffer that receives the value of the specified firmware environment variable.

nSize [in]

The size of the pBuffer buffer, in bytes.

Return value

If the function succeeds, the return value is the number of bytes stored in the pBuffer buffer.

If the function fails, the return value is zero. To get extended error information, call GetLastError. Possible error codes include ERROR_INVALID_FUNCTION.

Remarks

The exact set of firmware environment variables is determined by the boot firmware. The location of these environment variables is also specified by the firmware. For example, on a UEFI-based system, NVRAM contains firmware environment variables that specify system boot settings. For information about specific variables used, see the UEFI specification. For more information about UEFI and Windows, see UEFI and Windows.

Firmware variables are not supported on a legacy BIOS-based system. The GetFirmwareEnvironmentVariable function will always fail on a legacy BIOS-based system, or if Windows was installed using legacy BIOS on a system that supports both legacy BIOS and UEFI. To identify these conditions, call the function with a dummy firmware environment name such as an empty string ("") for the lpName parameter and a dummy GUID such as "{00000000-0000-0000-0000-000000000000}" for the lpGuid parameter. On a legacy BIOS-based system, or on a system that supports both legacy BIOS and UEFI where Windows was installed using legacy BIOS, the function will fail with ERROR_INVALID_FUNCTION. On a UEFI-based system, the function will fail with an error specific to the firmware, such as ERROR_NOACCESS, to indicate that the dummy GUID namespace does not exist.

If you are creating a backup application, you can use this function to save all the boot settings for the system so they can be restored using the SetFirmwareEnvironmentVariable function if needed.

Requirements

Minimum supported client

Windows Vista, Windows XP with SP1

Minimum supported server

Windows Server 2003

Header

Winbase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

Unicode and ANSI names

GetFirmwareEnvironmentVariableW (Unicode) and GetFirmwareEnvironmentVariableA (ANSI)

See also

SetFirmwareEnvironmentVariable
System Information Functions

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
This page should be updated to reflect the required privileges.      ZeZu   |   Edit   |   Show History
$0$0 $0 $0 {G|S}etFirmwareEnvironmentVariable requires SE_SYSTEM_ENVIRONMENT_NAME privilege.$0 $0Please update the page the documentation to reflect this.$0
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker