Пример #1
0
		static string CFStringGetString (IntPtr handle)
		{
			if (handle == IntPtr.Zero)
				return null;

			string str;

			int length = CFStringGetLength (handle);
			IntPtr unicode = CFStringGetCharactersPtr (handle);
			IntPtr buffer = IntPtr.Zero;

			if (unicode == IntPtr.Zero) {
				CFRange range = new CFRange (0, length);
				buffer = Marshal.AllocCoTaskMem (length * 2);
				CFStringGetCharacters (handle, range, buffer);
				unicode = buffer;
			}

			unsafe {
				str = new string ((char *) unicode, 0, length);
			}

			if (buffer != IntPtr.Zero)
				Marshal.FreeCoTaskMem (buffer);

			return str;
		}
Пример #2
0
		extern static void CFDataGetBytes (IntPtr handle, CFRange range, IntPtr buffer);
Пример #3
0
 extern static void CFDataGetBytes(IntPtr handle, CFRange range, IntPtr buffer);
Пример #4
0
		extern static IntPtr CFStringGetCharacters (IntPtr handle, CFRange range, IntPtr buffer);