C#...通过USB / iTunes连接到iPhone - 可能吗?

时间:2013-01-08 15:35:52

标签: c# iphone ios4 iphone-sdk-3.0 itunes-sdk

是否有人知道是否可以使用C#阅读/编辑iPhone的联系人列表,假设iPhone已通过USB连接线/ iTunes插入Windows PC?

2 个答案:

答案 0 :(得分:0)

您可以使用CFManzana / Manaza或MobileDevice dll连接iPhone。下面是一个如何做到这一点的例子。

// this variable will be declared in your class .

public static string devicename;

CFManzana.iDevice
phone = New iDevice();
phone.connect += phone_connect;

void phone_connect(object sender, ConnectEventArgs args)
        {
// here your will add your exception handling details.
           }

// now extract your device details.

devicename = phone.getDeviceName or phone.CopyValue("DeviceName"); \\it all depends what version of Manzana you have downloaded.

//now assign the value to the field 

this.txtname.text = devicename;

答案 1 :(得分:0)

如果你想通过USB连接到iOS设备,你可以试试我维护的imobiledevice-net NuGet包。例如,要列出当前连接到PC的所有iOS设备,您可以执行以下操作:

ReadOnlyCollection<string> udids;
int count = 0;

var idevice = LibiMobileDevice.Instance.iDevice;
var lockdown = LibiMobileDevice.Instance.Lockdown;

var ret = idevice.idevice_get_device_list(out udids, ref count);

if (ret == iDeviceError.NoDevice)
{
    // Not actually an error in our case
    return;
}

ret.ThrowOnError();

// Get the device name
foreach (var udid in udids)
{
    iDeviceHandle deviceHandle;
    idevice.idevice_new(out deviceHandle, udid).ThrowOnError();

    LockdownClientHandle lockdownHandle;
    lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, "Quamotion").ThrowOnError();

    string deviceName;
    lockdown.lockdownd_get_device_name(lockdownHandle, out deviceName).ThrowOnError();

    deviceHandle.Dispose();
    lockdownHandle.Dispose();
}