public IntPtr Handle { get; private set; }
- [DllImport (CoreFoundationLibrary, CharSet=CharSet.Unicode)]
+ [DllImport (CoreFoundationLibrary)]
extern static IntPtr CFRetain (IntPtr handle);
void Retain ()
CFRetain (Handle);
}
- [DllImport (CoreFoundationLibrary, CharSet=CharSet.Unicode)]
+ [DllImport (CoreFoundationLibrary)]
extern static IntPtr CFRelease (IntPtr handle);
void Release ()
}
}
- [DllImport (CoreFoundationLibrary, CharSet=CharSet.Unicode)]
+ [DllImport (CoreFoundationLibrary)]
extern static IntPtr CFStringGetCharactersPtr (IntPtr handle);
- [DllImport (CoreFoundationLibrary, CharSet=CharSet.Unicode)]
+ [DllImport (CoreFoundationLibrary)]
extern static IntPtr CFStringGetCharacters (IntPtr handle, CFRange range, IntPtr buffer);
public static string AsString (IntPtr handle)
return null;
int len = CFStringGetLength (handle);
+
+ if (len == 0)
+ return string.Empty;
+
IntPtr chars = CFStringGetCharactersPtr (handle);
IntPtr buffer = IntPtr.Zero;
-
+
if (chars == IntPtr.Zero) {
CFRange range = new CFRange (0, len);
- buffer = Marshal.AllocCoTaskMem (len * 2);
+ buffer = Marshal.AllocHGlobal (len * 2);
CFStringGetCharacters (handle, range, buffer);
chars = buffer;
}
}
if (buffer != IntPtr.Zero)
- Marshal.FreeCoTaskMem (buffer);
+ Marshal.FreeHGlobal (buffer);
return str;
}
CFProxy[] proxies = new CFProxy [array.Count];
for (int i = 0; i < proxies.Length; i++) {
- CFDictionary dict = new CFDictionary (array[i], true);
+ CFDictionary dict = new CFDictionary (array[i], false);
proxies[i] = new CFProxy (dict);
}
CFProxy[] proxies = new CFProxy [array.Count];
for (int i = 0; i < proxies.Length; i++) {
- CFDictionary dict = new CFDictionary (array[i], true);
+ CFDictionary dict = new CFDictionary (array[i], false);
proxies[i] = new CFProxy (dict);
}