Desktop Functions: Smart Device Functions:
|
CreateProfile (userenv)
C# Signature:
[DllImport("userenv.dll", SetLastError = true, CharSet = CharSet.Auto)] VB Signature:User-Defined Types:None. Alternative Managed API:Do you know one? Please contribute it! Notes:None. Tips & Tricks:pszProfilePath's capacity must not exceed 260 characters or CreateProfile will return error code 0x800706f7. Sample Code:
using (System.Security.Principal.WindowsIdentity i = new System.Security.Principal.WindowsIdentity(token)) Sample PowerShell Code:# Attempts to create a profile for the current logged on user. Obviously, this will not work and it generates a return code # of -2147024809. $TypeDefinition=@" [DllImport("userenv.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int CreateProfile([MarshalAs(UnmanagedType.LPWStr)] String pszUserSid, [MarshalAs(UnmanagedType.LPWStr)] String pszUserName, [Out, MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszProfilePath, uint cchProfilePath); "@ $u=Add-Type $token=[System.Security.Principal.WindowsIdentity]::GetCurrent().Token [System.Security.Principal.WindowsIdentity]$identity = new-object -TypeName System.Security.Principal.WindowsIdentity($token) $identity.Owner.Value $identity.Name $pathProfile="" $intThing=0 $u::CreateProfile($identity.Owner.Value, $identity.Name, $ProfilePath, $intSizeOfProfilePath) $ProfilePath $intSizeOfProfilePath Please edit this page!Do you have...
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). |
|