SetCurrentUser (Windows Embedded CE 6.0)
1/6/2010
This function sets the current user as logged on.
Syntax
BOOL SetCurrentUser(
LPCWSTR lpszUserName,
LPBYTE lpbUserSecret,
DWORD dwDataSize,
BOOL bCreateIfNew
);
Parameters
- lpszUserName
[in] NULL-terminated string containing the user's logon name. The name must be a valid file name because a directory is created for the user profile. User names are case-insensitive.
- lpbUserSecret
[in] Buffer of user-specific encrypted data, such as a password.
- dwDataSize
[in] Size of the user secret data.
- bCreateIfNew
[in] Specifies that a new user is created if the name specified in lpszUserName does not already exist on the system.
Return Value
Returns TRUE if the new user was logged on. If the specified user was already logged on, returns FALSE and leaves that user logged on. In this case, GetLastError returns ERROR_USER_EXISTS. If the call fails for any other reason, this function returns FALSE and logs the current user off.
Remarks
This function is accessible only to privileged applications.
When the user is logged on, this function adjusts the registry as applicable and provides the user encrypted data to the security subsystem to unlock the user credentials. This function logs off any previous user.
If the new user is the same as the previous user, the call fails, and GetLastError returns ERROR_USER_EXISTS, leaving the same user logged on. It makes no call to the security subsystem. In any other case when this function fails, the current user is logged off, and no new user is logged on.
If there is no user, set lpszUserName and lpbUserSecret to NULL, dwDataSize to zero, and bCreateIfNew to FALSE.
Requirements
Header | pwinreg.h |
Library | coredll.lib |
Windows Embedded CE | Windows CE .NET 4.0 and later |
See Also
Reference
User Management Functions
SetUserData
GetUserNameEx
RegReplaceKey
RegSaveKey