48
48
[DllImport (CFLib, EntryPoint="CFRelease")]
49
49
public static extern void Release (IntPtr cfRef);
52
public int Location, Length;
53
public CFRange (int l, int len)
60
[DllImport (CFLib, CharSet=CharSet.Unicode)]
61
extern static int CFStringGetLength (IntPtr handle);
63
[DllImport (CFLib, CharSet=CharSet.Unicode)]
64
extern static IntPtr CFStringGetCharactersPtr (IntPtr handle);
66
[DllImport (CFLib, CharSet=CharSet.Unicode)]
67
extern static IntPtr CFStringGetCharacters (IntPtr handle, CFRange range, IntPtr buffer);
69
public static string FetchString (IntPtr handle)
71
if (handle == IntPtr.Zero)
76
int l = CFStringGetLength (handle);
77
IntPtr u = CFStringGetCharactersPtr (handle);
78
IntPtr buffer = IntPtr.Zero;
79
if (u == IntPtr.Zero){
80
CFRange r = new CFRange (0, l);
81
buffer = Marshal.AllocCoTaskMem (l * 2);
82
CFStringGetCharacters (handle, r, buffer);
86
str = new string ((char *) u, 0, l);
89
if (buffer != IntPtr.Zero)
90
Marshal.FreeCoTaskMem (buffer);