| UserAccountControlIsProcessElevated Method |
The function gets the elevation information of the current process. It
dictates whether the process is elevated or not. Token elevation is only
available on Windows Vista and newer operating systems, thus
IsProcessElevated throws a C++ exception if it is called on systems prior
to Windows Vista. It is not appropriate to use this function to determine
whether a process is run as administrator.
Namespace: TomsToolbox.DesktopAssembly: TomsToolbox.Desktop (in TomsToolbox.Desktop.dll) Version: 2.21.0+44d18b541fc9419ec3c549350a832394661b2a4d
XMLNS for XAML: Not mapped to an xmlns.
Syntax public static bool IsProcessElevated()
Public Shared Function IsProcessElevated As Boolean
Return Value
Boolean
Returns true if the process is elevated. Returns false if it is not.
Exceptions Exception | Condition |
---|
Win32Exception |
When any native Windows API call fails, the function throws a Win32Exception
with the last error code.
|
Remarks
TOKEN_INFORMATION_CLASS provides TokenElevationType to check the elevation
type (TokenElevationTypeDefault / TokenElevationTypeLimited /
TokenElevationTypeFull) of the process. It is different from TokenElevation
in that, when UAC is turned off, elevation type always returns
TokenElevationTypeDefault even though the process is elevated (Integrity
Level == High). In other words, it is not safe to say if the process is
elevated based on elevation type. Instead, we should use TokenElevation.
See Also