TreeSetNamedSecurityInfo

C# Signature:

[DllImport("advapi32.dll", EntryPoint = "TreeSetNamedSecurityInfoW", SetLastError = true, CharSet = CharSet.Unicode)]
static extern uint TreeSetNamedSecurityInfo(string pObjectName, SE_OBJECT_TYPE ObjectType, SecurityInformation SecurityInfo,
                        IntPtr pOwner, IntPtr pGroup, IntPtr pDacl, IntPtr pSacl, uint dwAction, 
                        TreeSetNamedSecurityProgress fnProgress, PROGRESS_INVOKE_SETTING ProgressInvokeSetting, IntPtr Args);

// callback function
public delegate void TreeSetNamedSecurityProgress(IntPtr pObjectName, uint Status, IntPtr pInvokeSetting, IntPtr Args, Boolean SecuritySet);

User-Defined Types:

protected enum SE_OBJECT_TYPE
    {
        SE_UNKNOWN_OBJECT_TYPE = 0,
        SE_FILE_OBJECT,
        SE_SERVICE,
        SE_PRINTER,
        SE_REGISTRY_KEY,
        SE_LMSHARE,
        SE_KERNEL_OBJECT,
        SE_WINDOW_OBJECT,
        SE_DS_OBJECT,
        SE_DS_OBJECT_ALL,
        SE_PROVIDER_DEFINED_OBJECT,
        SE_WMIGUID_OBJECT,
        SE_REGISTRY_WOW64_32KEY
    }

    protected const uint TREE_SEC_INFO_SET   = 0x00000001;
    protected const uint TREE_SEC_INFO_RESET = 0x00000002;
    protected const uint TREE_SEC_INFO_RESET_KEEP_EXPLICIT = 0x00000003;

    public enum PROGRESS_INVOKE_SETTING 
    { 
        ProgressInvokeNever     = 1,
        ProgressInvokeEveryObject,
        ProgressInvokeOnError,
        ProgressCancelOperation,
        ProgressRetryOperation,
        ProgressInvokePrePostError
    }

Sample Code:

Sample Code:

Última actualización