xcode – 在c#中开发类似应用程序的iTunes
发布时间:2020-12-14 19:36:42 所属栏目:百科 来源:网络整理
导读:我需要在c#中开发一个应用程序,它可以在连接到系统时自动检测iPhone并读取iPhone文件系统的特定文件.我基本上希望将此文件从设备自动下载到PC.我使用USBpcap工具表明iTunes使用某种 XML格式连接到手机.任何帮助或见解非常感谢.是否有任何可以让我入门的第三
我需要在c#中开发一个应用程序,它可以在连接到系统时自动检测iPhone并读取iPhone文件系统的特定文件.我基本上希望将此文件从设备自动下载到PC.我使用USBpcap工具表明iTunes使用某种
XML格式连接到手机.任何帮助或见解非常感谢.是否有任何可以让我入门的第三方API文档?有些应用程序可以复制iTunes功能,例如
Copytrans
是否有Apple提供的协议或API? 我一直在挖掘互联网,发现此链接Layered communication for iPhone. 在我看来,我必须在Windows应用程序中实现usbmuxd.它是一种多层协议.必须有一些库实现usbmuxd(我不认为我必须自己实现协议) 我对iTunes通信以及USB通信都不太了解.我正在尽可能多地添加信息(当然还有我在R& D中提出的内容).任何帮助都非常感谢. public static DateTime LastDataEventDate = DateTime.Now; public static UsbDevice MyUsbDevice; #region SET YOUR USB Vendor and Product ID! public static UsbDeviceFinder MyUsbFinder = new UsbDeviceFinder(1452,4768); #endregion private void LibUSB() { ErrorCode ec = ErrorCode.None; try { // Find and open the usb device. MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder); // If the device is open and ready if (MyUsbDevice == null) throw new Exception("Device Not Found."); // If this is a "whole" usb device (libusb-win32,linux libusb) // it will have an IUsbDevice interface. If not (WinUSB) the // variable will be null indicating this is an interface of a // device. IUsbDevice wholeUsbDevice = MyUsbDevice as IUsbDevice; if (!ReferenceEquals(wholeUsbDevice,null)) { // This is a "whole" USB device. Before it can be used,// the desired configuration and interface must be selected. // Select config #1 wholeUsbDevice.SetConfiguration(1); // Claim interface #0. wholeUsbDevice.ClaimInterface(0); } // open read endpoint 1. UsbEndpointReader reader = MyUsbDevice.OpenEndpointReader(ReadEndpointID.Ep03); // open write endpoint 1. UsbEndpointWriter writer = MyUsbDevice.OpenEndpointWriter(WriteEndpointID.Ep02); int bytesWritten; ec = writer.Write(usbmux_header.GetBytes(),2000,out bytesWritten); if (ec != ErrorCode.None) throw new Exception(UsbDevice.LastErrorString); byte[] readBuffer = new byte[1024]; while (ec == ErrorCode.None) { int bytesRead; // If the device hasn't sent data in the last 100 milliseconds,// a timeout error (ec = IoTimedOut) will occur. ec = reader.Read(readBuffer,10000,out bytesRead); if (ec == ErrorCode.Win32Error) throw new Exception("port not open"); if (bytesRead == 0) throw new Exception("No more bytes!"); // Write that output to the console. Console.Write(Encoding.Default.GetString(readBuffer,bytesRead)); } } catch (Exception ex) { Console.WriteLine(); Console.WriteLine((ec != ErrorCode.None ? ec + ":" : String.Empty) + ex.Message); } finally { if (MyUsbDevice != null) { if (MyUsbDevice.IsOpen) { // If this is a "whole" usb device (libusb-win32,linux libusb-1.0) // it exposes an IUsbDevice interface. If not (WinUSB) the // 'wholeUsbDevice' variable will be null indicating this is // an interface of a device; it does not require or support // configuration and interface selection. IUsbDevice wholeUsbDevice = MyUsbDevice as IUsbDevice; if (!ReferenceEquals(wholeUsbDevice,null)) { // Release interface #0. wholeUsbDevice.ReleaseInterface(0); } MyUsbDevice.Close(); } MyUsbDevice = null; // Free usb resources UsbDevice.Exit(); } } } class usbmux_header { public static UInt32 length = 10; // length of message,including header public static UInt32 reserved = 0; // always zero public static UInt32 type = 3; // message type public static UInt32 tag = 2; // responses to this query will echo back this tag public static byte[] GetBytes() { byte[] lgth = BitConverter.GetBytes(length); byte[] res = BitConverter.GetBytes(reserved); byte[] tpe = BitConverter.GetBytes(type); byte[] tg = BitConverter.GetBytes(tag); byte[] retArray = new byte[16]; lgth.CopyTo(retArray,0); res.CopyTo(retArray,4); tpe.CopyTo(retArray,8); tg.CopyTo(retArray,12); return retArray; } }; 我一直在尝试向iPhone发送hello数据包字节,但我无法从手机中读取任何响应. 解决方法
要使用ipod,您可以使用
SharePodLib
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |