Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

DeleteProfile (userenv)
 
.
Summary
The DeleteProfile function 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.

C# Signature:

[DllImport("userenv", SetLastError=true)]

private static extern int DeleteProfile(string lpSidString, string lpProfilePath, string lpComputerName);

Notes:

    None

Tips & Tricks:

    None

Sample Code:

    // Get the user SID using the Win32Security library. Get this lib at www.gotdotnet.com
    Sid oSid = new Sid(@"csharp\test");
    int retValue = DeleteProfile(oSid.SidString, null, "SERVER01");

    // According to API documentation at MSDN 0 is returned when an error has occurred, so let's throw a Win32Exception when this happens.
    if (retValue == 0)
        throw new Win32Exception(Marshal.GetLastWin32Error());

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions