Export (0) Print
Expand All
Expand Minimize

UnloadUserProfile function

Unloads a user's profile that was loaded by the LoadUserProfile function. The caller must have administrative privileges on the computer. For more information, see the Remarks section of the LoadUserProfile function.

Syntax


BOOL WINAPI UnloadUserProfile(
  _In_  HANDLE hToken,
  _In_  HANDLE hProfile
);

Parameters

hToken [in]

Type: HANDLE

Token for the user, returned from the LogonUser, CreateRestrictedToken, DuplicateToken, OpenProcessToken, or OpenThreadToken function. The token must have TOKEN_IMPERSONATE and TOKEN_DUPLICATE access. For more information, see Access Rights for Access-Token Objects.

hProfile [in]

Type: HANDLE

Handle to the registry key. This value is the hProfile member of the PROFILEINFO structure. For more information see the Remarks section of LoadUserProfile and Registry Key Security and Access Rights.

Return value

Type: BOOL

TRUE if successful; otherwise, FALSE. To get extended error information, call GetLastError.

Remarks

Before calling UnloadUserProfile you should ensure that all handles to keys that you have opened 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.

For more information about calling functions that require administrator privileges, see Running with Special Privileges.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Userenv.h

Library

Userenv.lib

DLL

Userenv.dll

See also

User Profiles Overview
User Profiles Reference
LoadUserProfile
PROFILEINFO

 

 

Community Additions

ADD
Show:
© 2014 Microsoft