iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了xcode – 在c#中开发类似应用程序的iTunes大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我需要在c#中开发一个应用程序,它可以在连接到系统时自动检测iPhone并读取iPhone文件系统的特定文件.我基本上希望将此文件从设备自动下载到PC.我使用USBpcap工具表明iTunes使用某种 XML格式连接到手机.任何帮助或见解非常感谢.是否有任何可以让我入门的第三方API文档?有些应用程序可以复制iTunes功能,例如 Copytrans 是否有Apple提供的协议或API? 我一直在
我需要在c#中开发一个应用程序,它可以在连接到系统时自动检测iPhone并读取iPhone文件系统的特定文件.我基本上希望将此文件从设备自动下载到PC.我使用USBpcap工具表明iTunes使用某种 XML格式连接到手机.任何帮助或见解非常感谢.是否有任何可以让我入门的第三方api文档?有些应用程序可以复制iTunes功能,例如 Copytrans

是否有Apple提供的协议或API?

我一直在挖掘互联网,发现此链接Layered communication for iPhone.
我也使用LibUsbDotNet库与USB设备进行通信(Example).任何人都可以建议应该使用哪个EndPoints.

在我看来,我必须在Windows应用程序中实现usbmuxd.它是一种多层协议.必须有一些库实现usbmuxd(我不认为我必须自己实现协议)

我对iTunes通信以及USB通信都不太了解.我正在尽可能多地添加信息(当然还有我在R& D中提出的内容).任何帮助都非常感谢.

public static datetiR_567_11845@e LastDataEventDate = datetiR_567_11845@e.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

大佬总结

以上是大佬教程为你收集整理的xcode – 在c#中开发类似应用程序的iTunes全部内容,希望文章能够帮你解决xcode – 在c#中开发类似应用程序的iTunes所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。