Exemplo n.º 1
0
        public static T AEGetNthPtr <T> (ref AEDesc descList, int index, CarbonEventParameterType desiredType) where T : struct
        {
            int    len       = Marshal.SizeOf(typeof(T));
            IntPtr bufferPtr = Marshal.AllocHGlobal(len);

            try {
                CheckReturn((int)AEGetNthPtr(ref descList, index, desiredType, 0, 0, bufferPtr, len, 0));
                T val = (T)Marshal.PtrToStructure(bufferPtr, typeof(T));
                return(val);
            } finally{
                Marshal.FreeHGlobal(bufferPtr);
            }
        }
Exemplo n.º 2
0
        public static List <string> GetUrlListFromEventRef(IntPtr eventRef)
        {
            AEDesc list  = GetEventParameter <AEDesc> (eventRef, CarbonEventParameterName.DirectObject, CarbonEventParameterType.AEList);
            long   count = AECountItems(ref list);
            var    files = new List <string> ();

            for (int i = 1; i <= count; i++)
            {
                string url = GetStringFromAEPtr(ref list, i);
                if (!string.IsNullOrEmpty(url))
                {
                    files.Add(url);
                }
            }
            Carbon.CheckReturn(Carbon.AEDisposeDesc(ref list));
            return(files);
        }
Exemplo n.º 3
0
        public static List <string> GetFileListFromEventRef(IntPtr eventRef)
        {
            AEDesc list  = GetEventParameter <AEDesc> (eventRef, CarbonEventParameterName.DirectObject, CarbonEventParameterType.AEList);
            long   count = AECountItems(ref list);
            var    files = new List <string> ();

            for (int i = 1; i <= count; i++)
            {
                FSRef  fsRef = AEGetNthPtr <FSRef> (ref list, i, CarbonEventParameterType.FSRef);
                string file  = FSRefToPath(ref fsRef);
                if (!string.IsNullOrEmpty(file))
                {
                    files.Add(file);
                }
            }
            CheckReturn(AEDisposeDesc(ref list));
            return(files);
        }
Exemplo n.º 4
0
        //FIXME: this might not work in some encodings. need to test more.
        static string GetStringFromAEPtr(ref AEDesc descList, int index)
        {
            int size;
            CarbonEventParameterType type = CarbonEventParameterType.UnicodeText;

            if (AESizeOfNthItem(ref descList, index, ref type, out size) == AEDescStatus.Ok)
            {
                IntPtr buffer = Marshal.AllocHGlobal(size);
                try {
                    if (AEGetNthPtr(ref descList, index, type, 0, 0, buffer, size, 0) == AEDescStatus.Ok)
                    {
                        return(Marshal.PtrToStringAuto(buffer, size));
                    }
                } finally {
                    Marshal.FreeHGlobal(buffer);
                }
            }
            return(null);
        }
Exemplo n.º 5
0
 public static extern AEDescStatus AESizeOfNthItem(ref AEDesc descList, int index, ref CarbonEventParameterType type, out int size);
Exemplo n.º 6
0
 public static extern int AEDisposeDesc(ref AEDesc desc);
Exemplo n.º 7
0
 static extern AEDescStatus AEGetNthPtr(ref AEDesc descList, int index, CarbonEventParameterType desiredType, uint keyword,
                                        uint zero, out IntPtr outPtr, int bufferSize, int zero2);
Exemplo n.º 8
0
 static extern AEDescStatus AEGetNthPtr(ref AEDesc descList, int index, CarbonEventParameterType desiredType, uint keyword,
                                        out CarbonEventParameterType actualType, IntPtr buffer, int bufferSize, out int actualSize);
Exemplo n.º 9
0
 static extern int AECountItems(ref AEDesc descList, out int count);          //return an OSErr