private KNOWNFOLDER_DEFINITION(ref KNOWNFOLDER_DEFINITION_RAW d, KnownFolderDefinitionHandles h)
        {
            this.category     = d.category;
            this.fidParent    = d.fidParent;
            this.dwAttributes = d.dwAttributes;
            this.kfdFlags     = d.kfdFlags;
            this.ftidType     = d.ftidType;

            this.name          = UnmarshalString(h.hName, "hName");
            this.description   = UnmarshalString(h.hDescription, "hDescription");
            this.relativePath  = UnmarshalString(h.hRelativePath, "hRelativePath");
            this.parsingName   = UnmarshalString(h.hParsingName, "hParsingName");
            this.toolTip       = UnmarshalString(h.hToolTip, "hToolTip");
            this.localizedName = UnmarshalString(h.hLocalizedName, "hLocalizedName");
            this.icon          = UnmarshalString(h.hIcon, "hIcon");
            this.security      = UnmarshalString(h.hSecurity, "hSecurity");
        }
        private KNOWNFOLDER_DEFINITION(ref KNOWNFOLDER_DEFINITION_RAW d, KnownFolderDefinitionHandles h)
        {
            this.category = d.category;
            this.fidParent = d.fidParent;
            this.dwAttributes = d.dwAttributes;
            this.kfdFlags = d.kfdFlags;
            this.ftidType = d.ftidType;

            this.name = UnmarshalString(h.hName, "hName");
            this.description = UnmarshalString(h.hDescription, "hDescription");
            this.relativePath = UnmarshalString(h.hRelativePath, "hRelativePath");
            this.parsingName = UnmarshalString(h.hParsingName, "hParsingName");
            this.toolTip = UnmarshalString(h.hToolTip, "hToolTip");
            this.localizedName = UnmarshalString(h.hLocalizedName, "hLocalizedName");
            this.icon = UnmarshalString(h.hIcon, "hIcon");
            this.security = UnmarshalString(h.hSecurity, "hSecurity");
        }
        public static KNOWNFOLDER_DEFINITION FromKnownFolder(IKnownFolder knownFolder)
        {
            if (knownFolder == null)
            {
                throw new ArgumentNullException("knownFolder");
            }

            KNOWNFOLDER_DEFINITION def;

            using (var handles = new KnownFolderDefinitionHandles())
            {
                KNOWNFOLDER_DEFINITION_RAW rawDef;

                RuntimeHelpers.PrepareConstrainedRegions();
                try
                {
                }
                finally
                {
                    knownFolder.GetFolderDefinition(out rawDef);
                    try
                    {
                        handles.SecureHandles(ref rawDef);
                    }
                    finally
                    {
                        // in case SecureHandles throws
                        rawDef.FreeKnownFolderDefinitionFields();
                    }
                }

                def = new KNOWNFOLDER_DEFINITION(ref rawDef, handles);
            }

            return(def);
        }
        public static KNOWNFOLDER_DEFINITION FromKnownFolder(IKnownFolder knownFolder)
        {
            if (knownFolder == null)
            {
                throw new ArgumentNullException("knownFolder");
            }

            KNOWNFOLDER_DEFINITION def;

            using (var handles = new KnownFolderDefinitionHandles())
            {
                KNOWNFOLDER_DEFINITION_RAW rawDef;

                RuntimeHelpers.PrepareConstrainedRegions();
                try
                {
                }
                finally
                {
                    knownFolder.GetFolderDefinition(out rawDef);
                    try
                    {
                        handles.SecureHandles(ref rawDef);
                    }
                    finally
                    {
                        // in case SecureHandles throws
                        rawDef.FreeKnownFolderDefinitionFields();
                    }
                }

                def = new KNOWNFOLDER_DEFINITION(ref rawDef, handles);
            }

            return def;
        }