Release() private method

private Release ( IntPtr cfRef ) : void
cfRef System.IntPtr
return void
Ejemplo n.º 1
0
        public static void SetMenuTitle(IntPtr menuRef, string title)
        {
            IntPtr           str    = CoreFoundation.CreateString(title);
            CarbonMenuStatus result = SetMenuTitleWithCFString(menuRef, str);

            CoreFoundation.Release(str);
            CheckResult(result);
        }
Ejemplo n.º 2
0
        public static ushort InsertMenuItem(IntPtr parentRef, string title, ushort afterItemIndex, MenuItemAttributes attributes, uint commandId)
        {
            ushort           index;
            IntPtr           str    = CoreFoundation.CreateString(title);
            CarbonMenuStatus result = InsertMenuItemTextWithCFString(parentRef, str, afterItemIndex, attributes, commandId, out index);

            CoreFoundation.Release(str);
            CheckResult(result);
            return(index);
        }
Ejemplo n.º 3
0
        public static string GetFolder(MacDomains domain, uint folderType)
        {
            FSRef reference;
            int   no = FSFindFolder(domain, folderType, false, out reference);

            if (no != 0)
            {
                throw new Exception(string.Format("domain: {0} type: {1} return: {2}", domain, folderType, no));
            }

            if (no != 0)
            {
                return(null);
            }

            IntPtr url = IntPtr.Zero;
            IntPtr str = IntPtr.Zero;

            try
            {
                url = CFURLCreateFromFSRef(IntPtr.Zero, ref reference);
                str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);

                CFRange range = new CFRange();
                range.location = (IntPtr)0;
                range.length   = (IntPtr)CFStringGetLength(str);

                char[] strdata = new char[(int)range.length];
                CFStringGetCharacters(str, range, strdata);
                return(new String(strdata));
            }
            finally
            {
                if (url != IntPtr.Zero)
                {
                    CoreFoundation.Release(url);
                }
                if (str != IntPtr.Zero)
                {
                    CoreFoundation.Release(str);
                }
            }
        }