SaferCreateLevel (advapi32)
Last changed: -84.9.35.116

.
Summary
The SaferCreateLevel function opens a SAFER_LEVEL_HANDLE.

C# Signature:

[DllImport("advapi32", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool SaferCreateLevel(uint dwScopeId, uint dwLevelId, int OpenFlags, out IntPtr
  pLevelHandle, IntPtr lpReserved);

VB Signature:

Declare Function SaferCreateLevel Lib "advapi32.dll" (ByVal dwScopeId As Long, ByVal dwLevelId As Long, ByVal OpenFlags As Long, pLevelHandle As Long, ByVal lpReserved As Long) As Long

User-Defined Types:

With these optional Enums:

[Flags]
public enum SaferLevelEnum
{
   Disallowed = 0,
   Untrusted = 0x1000,
   Constrained = 0x10000,
   NormalUser = 0x20000,
   FullyTrusted = 0x40000
}

[Flags]
public enum SaferScopeEnum
{
   Machine = 1,
   User = 2
}

You can then declare SaferCreateLevel as:

[DllImport("advapi32", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool SaferCreateLevel(uint dwScopeId, uint dwLevelId, int OpenFlags, out IntPtr
  pLevelHandle, IntPtr lpReserved);

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

Don't forget to close the handle using SaferCloseLevel.

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Documentation