Επεξεργασία

Κοινή χρήση μέσω


CreateProfile function (userenv.h)

Creates a new user profile.

Syntax

USERENVAPI HRESULT CreateProfile(
  [in]  LPCWSTR pszUserSid,
  [in]  LPCWSTR pszUserName,
  [out] LPWSTR  pszProfilePath,
  [in]  DWORD   cchProfilePath
);

Parameters

[in] pszUserSid

Type: LPCWSTR

Pointer to the SID of the user as a string.

[in] pszUserName

Type: LPCWSTR

The user name of the new user. This name is used as the base name for the profile directory.

[out] pszProfilePath

Type: LPWSTR

When this function returns, contains a pointer to the full path of the profile.

[in] cchProfilePath

Type: DWORD

Size of the buffer pointed to by pszProfilePath, in characters.

Return value

Type: HRESULT

Returns S_OK if successful, or an error value otherwise, including the following:

Return code Description
E_ACCESSDENIED
The caller does not have a sufficient permission level to create the profile.
HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS)
A profile already exists for the specified user.

Remarks

The caller must have administrator privileges to call this function.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header userenv.h
Library Userenv.lib
DLL Userenv.dll