Share via


SetCurrentUser (Windows CE 5.0)

Send Feedback

This function sets the current user as logged on.

BOOL SetCurrentUser( LPCWSTRlpszUserName, LPBYTElpbUserSecret, DWORDdwDataSize,BOOLbCreateIfNew );

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 that contains the user's personal data. User names are case-insensitive.
  • lpbUserSecret
    [in] Buffer of user-specific opaque secret data, such as a password.
  • dwDataSize
    [in] Size of the user secret data.
  • bCreateIfNew
    [in] Creates a new user if it does not already exist.

Return Values

This function returns TRUE if the new user was logged on. If the given user was already logged on, this function returns FALSE and leaves that user logged on. In this case, the GetLastError function returns ERROR_USER_EXISTS. If the call fails for any other reason, this function returns FALSE and logs off the current user.

Remarks

SetCurrentUser is accessible only to trusted applications.

When the user is logged on, this function adjusts the registry as applicable, and provides the user secret data to the security subsystem to unlock the user's credentials. This function logs off the previous user, if present.

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 and makes no call to the security subsystem. In any other case, when SetCurrentUser fails, the current user is logged off and no user will be logged on.

If no there is no user, set lpszUserName and lpbUserSecret to NULL, dwDataSize to zero, and bCreateIfNew to FALSE.

Requirements

OS Versions: Windows CE .NET 4.0 and later.
Header: Pwinreg.h.
Link Library: Coredll.lib.

See Also

SetUserData | GetUserNameEx | RegReplaceKey | RegSaveKey | Trusted APIs | User Management

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.