private static string GetSecurityPermissions(COMSD sdtype) { IntPtr sd = IntPtr.Zero; try { int hr = CoGetSystemSecurityPermissions(sdtype, out sd); if (hr != 0) { throw new Win32Exception(hr); } int length = GetSecurityDescriptorLength(sd); byte[] ret = new byte[length]; Marshal.Copy(sd, ret, 0, length); return(GetStringSDForSD(ret)); } finally { if (sd != IntPtr.Zero) { LocalFree(sd); } } }
private extern static int CoGetSystemSecurityPermissions(COMSD comSDType, out IntPtr ppSD);
public static extern HRESULT CoGetSystemSecurityPermissions(COMSD comSDType, [NativeTypeName("PSECURITY_DESCRIPTOR *")] void **ppSD);