AdvApi32 Class

Platform Invocation methods (P/Invoke), access unmanaged code.

AdvApi32.dll.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[HideModuleNameAttribute]
public sealed class AdvApi32
Inheritance
Object    AdvApi32

Methods

AbortSystemShutdown Aborts a system shutdown that has been initiated.
AdjustTokenPrivileges Enables or disables privileges in the specified access token.

Enabling or disabling privileges in an access token requires AdjustPrivileges access.

Note that AdjustTokenPrivileges(IntPtr, Boolean, TokenPrivileges, Int32, TokenPrivileges, IntPtr) cannot add or remove privileges from the token. It can only enable existing privileges that are currently disabled, or disable existing privileges that are currently enabled.

CreateProcessAsUser Creates a new process and its primary thread. The new process runs in the security context of the user represented by the specified token.

Typically, the process that calls the CreateProcessAsUser(IntPtr, String, StringBuilder, SecurityAttributes, SecurityAttributes, Boolean, CreateProcessFlags, IntPtr, String, ProcessStartupInfo, ProcessInformation) function must have the IncreaseQuotaPrivilege privilege and may require the AssignPrimaryTokenPrivilege privilege if the token is not assignable.

If this function fails with ERROR_PRIVILEGE_NOT_HELD (1314), use the CreateProcessWithLogon(String, String, String, ProcessLogonFlags, String, StringBuilder, CreateProcessFlags, IntPtr, String, ProcessStartupInfo, ProcessInformation) function instead. CreateProcessWithLogon(String, String, String, ProcessLogonFlags, String, StringBuilder, CreateProcessFlags, IntPtr, String, ProcessStartupInfo, ProcessInformation) requires no special privileges, but the specified user account must be allowed to log on interactively.

Generally, it is best to use CreateProcessWithLogon(String, String, String, ProcessLogonFlags, String, StringBuilder, CreateProcessFlags, IntPtr, String, ProcessStartupInfo, ProcessInformation) to create a process with alternate credentials.

CreateProcessWithLogon Creates a new process and its primary thread. Then the new process runs the specified executable file in the security context of the specified credentials (user, domain, and password). It can optionally load the user profile for a specified user.

This function is similar to the CreateProcessAsUser(IntPtr, String, StringBuilder, SecurityAttributes, SecurityAttributes, Boolean, CreateProcessFlags, IntPtr, String, ProcessStartupInfo, ProcessInformation) and CreateProcessWithToken(IntPtr, ProcessLogonFlags, String, StringBuilder, CreateProcessFlags, IntPtr, String, ProcessStartupInfo, ProcessInformation) functions, except that the caller does not need to call the LogonUser function to authenticate the user and get a token.

CreateProcessWithToken Creates a new process and its primary thread. The new process runs in the security context of the specified token. It can optionally load the user profile for the specified user.

The process that calls CreateProcessWithToken(IntPtr, ProcessLogonFlags, String, StringBuilder, CreateProcessFlags, IntPtr, String, ProcessStartupInfo, ProcessInformation) must have the ImpersonatePrivilege privilege. If this function fails with ERROR_PRIVILEGE_NOT_HELD (1314), use the CreateProcessAsUser(IntPtr, String, StringBuilder, SecurityAttributes, SecurityAttributes, Boolean, CreateProcessFlags, IntPtr, String, ProcessStartupInfo, ProcessInformation) or CreateProcessWithLogon(String, String, String, ProcessLogonFlags, String, StringBuilder, CreateProcessFlags, IntPtr, String, ProcessStartupInfo, ProcessInformation) function instead. Typically, the process that calls.

Generally, it is best to use CreateProcessWithLogon(String, String, String, ProcessLogonFlags, String, StringBuilder, CreateProcessFlags, IntPtr, String, ProcessStartupInfo, ProcessInformation) to create a process with alternate credentials.

CreateWellKnownSid Creates a SID for predefined aliases.
DuplicateToken Creates a new access token that duplicates one already in existence.
DuplicateTokenEx Creates a new access token that duplicates an existing token.

This function can create either a primary token or an impersonation token.

Equals Determines whether the specified object is equal to the current object.
(Inherited from Object)
GetHashCode Serves as the default hash function.
(Inherited from Object)
GetKernelObjectSecurity Retrieves a copy of the security descriptor that protects a kernel object.
GetTokenInformation Retrieves a specified type of information about an access token.

The calling process must have appropriate access rights to obtain the information.

GetType Gets the Type of the current instance.
(Inherited from Object)
ImpersonateAnonymousToken Enables the specified thread to impersonate the system's anonymous logon token.

To ensure that a token matches the operating system's concept of anonymous access, this function should be called before attempting network access to generate an anonymous token on the remote server.

ImpersonateLoggedOnUser Lets the calling thread impersonate the security context of a logged-on user. The user is represented by a token handle.
ImpersonateSelf Obtains an access token that impersonates the security context of the calling process. The token is assigned to the calling thread.
InitiateShutdown Initiates a shutdown and restart of the specified computer, and restarts any applications that have been registered for restart.
LookupPrivilegeDisplayName Retrieves the display name that represents a specified privilege.
LookupPrivilegeName Retrieves the name that corresponds to the privilege represented on a specific system by a specified locally unique identifier (LUID).
LookupPrivilegeValue Retrieves the locally unique identifier (LUID) used on a specified system, to locally represent the specified privilege name.
LsaNtStatusToWinError Converts an NTStatus value to a Win32ErrorCode value.
OpenProcessToken(IntPtr, TokenAccess, IntPtr) Opens the access token associated with a process.
OpenProcessToken(SafeHandle, TokenAccess, IntPtr) Opens the access token associated with a process.
OpenProcessToken(SafeProcessHandle, TokenAccess, IntPtr) Opens the access token associated with a process.
OpenThreadToken(IntPtr, TokenAccess, Boolean, IntPtr) Opens the access token associated with a thread.
OpenThreadToken(SafeHandle, TokenAccess, Boolean, IntPtr) Opens the access token associated with a thread.
PrivilegeCheck Determines whether a specified set of privileges are enabled in an access token.

This function is typically called by a server application to check the privileges of a client's access token.

RegCloseKey(IntPtr) Closes a handle to the specified registry key.
RegCloseKey(SafeRegistryHandle) Closes a handle to the specified registry key.
RegLoadKey(IntPtr, String, String) Creates a subkey under HKEY_USERS or HKEY_LOCAL_MACHINE and loads the data from the specified registry hive into that subkey.

Applications that back up or restore system state including system files and registry hives should use the Volume Shadow Copy service instead of the registry functions.

RegLoadKey(RegistryHive, String, String) Creates a subkey under HKEY_USERS or HKEY_LOCAL_MACHINE and loads the data from the specified registry hive into that subkey.

Applications that back up or restore system state including system files and registry hives should use the Volume Shadow Copy service instead of the registry functions.

RegLoadKey(SafeRegistryHandle, String, String) Creates a subkey under HKEY_USERS or HKEY_LOCAL_MACHINE and loads the data from the specified registry hive into that subkey.

Applications that back up or restore system state including system files and registry hives should use the Volume Shadow Copy service instead of the registry functions.

RegNotifyChangeKeyValue(IntPtr, Boolean, RegNotifyChangeFilter, IntPtr, Boolean) Notifies the caller about changes to the attributes or contents of a specified registry key.
RegNotifyChangeKeyValue(SafeRegistryHandle, Boolean, RegNotifyChangeFilter, IntPtr, Boolean) Notifies the caller about changes to the attributes or contents of a specified registry key.
RegOpenKeyEx(IntPtr, String, UInt32, Int32, IntPtr) Opens the specified registry key. Note that key names are not case sensitive.
RegOpenKeyEx(SafeRegistryHandle, String, UInt32, Int32, IntPtr) Opens the specified registry key. Note that key names are not case sensitive.
RegRenameKey(IntPtr, String, String) Renames a registry subkey.
RegRenameKey(RegistryHive, String, String) Renames a registry subkey.
RegRenameKey(SafeRegistryHandle, String, String) Renames a registry subkey.
RegUnLoadKey(IntPtr, String) Unloads the specified registry key and its subkeys from the registry.

Applications that back up or restore system state including system files and registry hives should use the Volume Shadow Copy service instead of the registry functions.

RegUnLoadKey(RegistryHive, String) Unloads the specified registry key and its subkeys from the registry.

Applications that back up or restore system state including system files and registry hives should use the Volume Shadow Copy service instead of the registry functions.

RegUnLoadKey(SafeRegistryHandle, String) Unloads the specified registry key and its subkeys from the registry.

Applications that back up or restore system state including system files and registry hives should use the Volume Shadow Copy service instead of the registry functions.

RevertToSelf Terminates the impersonation of a client application.
SetKernelObjectSecurity Sets the security of a kernel object. For example, this can be a process, thread, or event.
SetThreadToken Assigns an impersonation token to a thread. The function can also cause a thread to stop using an impersonation token.
ToString Returns a string that represents the current object.
(Inherited from Object)

Extension Methods

CanConvertTo Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions)
CanConvertToT Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions)
ConvertToT Converts an object to the specified target type.

If the conversion fails, an exception is thrown.
(Defined by ObjectExtensions)

ConvertToT Converts an object to the specified target type.

If the conversion fails, returns the specified default value.
(Defined by ObjectExtensions)

IsDisposable Determines whether the specified object is a disposable type (i.e., it implements IDisposable interface).
(Defined by ObjectExtensions)
Speak Speaks the string representation of the source object by using the operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions)
Speak Speaks the string representation of the source object by using the operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions)
ThrowIfNullTException Throws the specified exception if the source object is null.
(Defined by ObjectExtensions)

See Also