Communicate to PC over USB

半腔热情 提交于 2020-01-04 19:42:19

问题


How can I exchange data between my WP8 app and my desktop Windows app running on the PC that has the phone connected with a USB cable? On WP7, there was TCP/IP networking over USB connection. On WP8, it seems it no longer works.

On the device side, NetworkInterfaceList class lists the Ethernet adapter, however NetworkInformation.GetHostNames method says there is no IP address assigned to that NIC. Is there a way to assign an IP address to that NIC, and use it for phone-to-pc communication over the USB cable?

On the PC side, looks like the connectivity DLLs implement Smart Device Connectivity API. Where can I find Microsoft.Smartdevice.DeviceAgentTransport.dll for Windows Phone 8 platform?

Are there some other options?

P.S. I am not submitting anything to the marketplace, so private or undocumented APIs are OK for me.


回答1:


I was just looking for this one myself and found a good resource over at msdn, IP over USB. As long as you have the windows phone SDK installed you have everything.

Edit: A small update, it seems that the server code must be running on the device and the client on the host, but apart from that everything worked as expected.

  • Used regedit to add a new entry under HKEY_LOCAL_MACHINE\Software\Microsoft\IpOverUsbSDK and created values similar to other entries, just different ports.
  • It took a few seconds and a refresh of regedit for IpOverUsbEnum.exe to display the new service.


来源:https://stackoverflow.com/questions/16905253/communicate-to-pc-over-usb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!