Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than userenv, prefix the name with the module name and a period.
<DllImport("userenv.dll", EntryPoint:="LoadUserProfile", SetLastError:=True, CharSet:=CharSet.Auto)> _
Public Shared Function LoadUserProfile(ByVal hToken As IntPtr, ByRef lpProfileInfo As PROFILEINFO) As Boolean
End Function
[in, out] Pointer to a PROFILEINFO structure. LoadUserProfile will fail and return ERROR_INVALID_PARAMETER if the dwSize member of the structure is not set to sizeof(PROFILEINFO) or if the lpUserName member is NULL. For more information, see the following Remarks section.
Return Values
If the function succeeds, the return value is nonzero.
The function fails and returns ERROR_INVALID_PARAMETER if the dwSize member of the structure is not set to sizeof(PROFILEINFO) or if the lpUserName member is NULL.
Otherwise, if the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
When a user logs on interactively, the system automatically loads the user's profile. If a service or an application impersonates a user, the system does not load the user's profile. Therefore, the service or application should load the user's profile with LoadUserProfile.
Services and applications that call LoadUserProfile should check to see if the user has a roaming profile. If the user has a roaming profile, specify its path as the lpProfilePath member of PROFILEINFO. To retrieve the user's roaming profile path, you can call the NetUserGetInfo function, specifying information level 3 or 4.
Upon successful return, the hProfile member of PROFILEINFO is a registry key handle opened to the root of the user's hive. It has been opened with full access (KEY_ALL_ACCESS). If a service that is impersonating a user needs to read or write to the user's registry file, use this handle instead of HKEY_CURRENT_USER. Do not close the hProfile handle. Instead, pass it to the UnloadUserProfile function. This function closes the handle. You should ensure that all handles to keys in the user's registry hive are closed. If you do not close all open registry handles, the user's profile fails to unload. For more information, see Registry Key Security and Access Rights and Registry Hives.
Note that it is your responsibility to load the user's registry hive into the HKEY_USERS registry key with the LoadUserProfile function before calling CreateProcessAsUser. This is because CreateProcessAsUser does not load the specified user's profile into HKEY_USERS. This means that access to information in the HKEY_CURRENT_USER registry key may not produce results consistent with a normal interactive logon.
The calling process must have the SE_RESTORE_NAME and SE_BACKUP_NAME privileges. For more information, see Running with Special Privileges.
Tips & Tricks:
Please add some!
Sample Code:
Please add some!
TODO - a short description
7/12/2007 6:24:33 PM - -194.176.105.42
TODO - a short description
6/20/2007 4:00:29 AM - -24.118.142.62
The LogonUserEx function attempts to log a user on to the local computer. The local computer is the computer from which LogonUserEx was called. You cannot use LogonUserEx to log on to a remote computer. You specify the user with a user name and domain, and authenticate the user with a plaintext password. If the function succeeds, you receive a handle to a token that represents the logged-on user. You can then use this token handle to impersonate the specified user or, in most cases, to create a process that runs in the context of the specified user.
11/24/2010 12:30:59 PM - -95.223.169.177
The DuplicateTokenEx function creates a new access token that duplicates an existing token. This function can create either a primary token or an impersonation token.
11/19/2012 3:33:05 AM - -213.199.128.148
Opens a handle to the access token associated with a process.
4/19/2010 2:03:23 PM - -149.173.6.25
Opens the access token associated with a thread
3/16/2007 7:33:52 AM - anfortas.geo@yahoo.com-216.204.61.86
TODO - a short description
6/20/2007 4:00:29 AM - -24.118.142.62
TODO - a short description
6/20/2007 4:00:29 AM - -24.118.142.62
TODO - a short description
6/20/2007 4:00:29 AM - -24.118.142.62
TODO - a short description
2/8/2008 7:50:29 AM - webdistortion.com-80.76.207.209
TODO - a short description
6/30/2008 7:37:24 PM - -71.187.214.117
TODO - a short description
6/20/2007 4:00:29 AM - -24.118.142.62
Creates a new process, using the creditials supplied by hToken. The application opened is running under the credentials and authority for the user supplied to LogonUser.
4/21/2013 11:21:50 PM - -203.19.158.31
Creates a new process, using the creditials supplied by hToken. The application opened is running under the credentials and authority for the user supplied to LogonUser.
4/21/2013 11:21:50 PM - -203.19.158.31
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).