NTSTATUS
NtQuerySystemEnvironmentValueEx(
  IN  PUNICODE_STRING VariableName,
  IN  LPGUID VendorGuid,
  OUT PVOID Value,
  IN OUT PULONG ValueLength,
  OUT PULONG Attributes OPTIONAL
  );

Routine Description:

    This function locates the specified system environment variable and
    return its value.

    N.B. This service requires the system environment privilege.

Arguments:

    VariableName - Supplies a pointer to a UNICODE descriptor for the specified
        system environment variable.

    VendorGuid - Supplies the GUID for the vendor associated with the variable.
        Variables are grouped into namespaces based on their vendor GUIDs. Some
        platforms may not support vendor GUIDs. On these platforms, all
        variables are in a single namespace, and this routine ignores VendorGuid.

    Value - Supplies a pointer to a buffer that receives the value of the
        specified system environment variable.

    ValueLength - On input, supplies the length in bytes of the Value buffer.
        On output, returns the length in bytes of the variable value. If the
        input buffer is large enough, then ValueLength indicates the amount
        of data copied into Value. If the input buffer is too small, then
        nothing is copied into the buffer, and ValueLength indicates the
        required buffer length.

    Attributes - Supplies an optional pointer to a ULONG to receive the
        attributes of the variable.

Return Value:

    STATUS_SUCCESS              The function succeeded.
    STATUS_INSUFFICIENT_RESOURCES Insufficient system resources exist
                                  for this request to complete.
    STATUS_BUFFER_TOO_SMALL     The input buffer was too small.
    STATUS_VARIABLE_NOT_FOUND   The requested variable does not exist.
    STATUS_INVALID_PARAMETER    One of the parameters is invalid.
    STATUS_NOT_IMPLEMENTED      This function is not supported on this platform.
    STATUS_UNSUCCESSFUL         The firmware returned an unrecognized error.
    STATUS_PRIVILEGE_NOT_HELD   The caller does not have the required privilege.
    STATUS_ACCESS_VIOLATION     One of the input parameters cannot be read,
                                or one of the output parameters cannot be written.