DeleteProfileW function (userenv.h)

Deletes the user profile and all user-related settings from the specified computer. The caller must have administrative privileges to delete a user's profile.

Syntax

USERENVAPI BOOL DeleteProfileW(
  [in]           LPCWSTR lpSidString,
  [in, optional] LPCWSTR lpProfilePath,
  [in, optional] LPCWSTR lpComputerName
);

Parameters

[in] lpSidString

Type: LPCTSTR

Pointer to a string that specifies the user SID.

[in, optional] lpProfilePath

Type: LPCTSTR

Pointer to a string that specifies the profile path. If this parameter is NULL, the function obtains the path from the registry.

[in, optional] lpComputerName

Type: LPCTSTR

Pointer to a string that specifies the name of the computer from which the profile is to be deleted. If this parameter is NULL, the local computer name is used.

Note  As of Windows Vista, this parameter must be NULL. If it is not, this function fails with the error code ERROR_INVALID_PARAMETER.
 

Return value

Type: BOOL

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

Remarks

DeleteProfile might fail when passed the security identifier (SID) of the local system account (S-1-5-18).

Note

The userenv.h header defines DeleteProfile as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

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

See also

User Profiles Overview

User Profiles Reference