我需要找到我的軟件正在運行的手機的IP地址。我會認爲這是直接的,但已經搜索論壇似乎(難以置信的是)在Windows Phone 7中沒有這種方法 - 但是,這在Windows Phone 8中有所改變嗎?任何幫助,將不勝感激。windows phone 8中的IP地址
14
A
回答
3
當然有一種方法可以找到手機的IP地址。這裏是一個MSDN博客博客文章,它解釋瞭如何做到這一點:Finding Your Own IP Address On Windows Phone Mango
我剛剛在我的諾基亞Lumia 920(Windows Phone 8)上測試它,它工作得很好。但是,由於使用了多播IP,這隻適用於WiFi。
16
是的,現在可以在WP8中使用WP7所需的多播解決方案。請注意,你有你自己的手機上有多個網絡接口(例如,三個在我的WP8模擬器)
public static IPAddress Find()
{
List<string> ipAddresses = new List<string>();
var hostnames = NetworkInformation.GetHostNames();
foreach (var hn in hostnames)
{
if (hn.IPInformation != null)
{
string ipAddress = hn.DisplayName;
ipAddresses.Add(ipAddress);
}
}
IPAddress address = IPAddress.Parse(ipAddresses[0]);
return address;
}
HTH
0
代號爲Windows RT
public static string GetIpAddress()
{
var address = "";
var icp = NetworkInformation.GetInternetConnectionProfile();
if (icp != null && icp.NetworkAdapter != null)
{
var hostname =
NetworkInformation.GetHostNames()
.SingleOrDefault(
hn =>
hn.IPInformation != null && hn.IPInformation.NetworkAdapter != null
&& hn.IPInformation.NetworkAdapter.NetworkAdapterId
== icp.NetworkAdapter.NetworkAdapterId);
if (hostname != null)
{
address = hostname.CanonicalName;
}
}
return address;
}
相關問題
- 1. Windows Phone 8 - Mac地址
- 2. Windows Phone 8藍牙地址
- 3. 針對Windows Phone 8模擬器的不同IP地址
- 4. Windows Phone 8. Ip配置
- 5. Windows 8中的Windows Phone 8
- 6. Windows Phone 8中的YouTube網址
- 7. 本地化的Windows Phone 8
- 8. 知道Windows Phone中USB共享接口的IP地址
- 9. Windows Phone 8地圖XAMLParseException
- 10. Windows Phone 8地圖uri scheme
- 11. Windows Phone 8中的Google地圖API
- 12. Windows Phone 8中的本地Toast通知
- 13. Windows Phone 8中的本地通知
- 14. LongListSelector中的Windows Phone 7或Windows Phone 8
- 15. Windows Phone的8
- 16. Windows 8和Windows Phone 8
- 17. Windows Phone 8地圖覆蓋/地區
- 18. windows phone 8舊地圖vs新地圖
- 19. 如何以編程方式獲取Windows 7/8/8.1/10手機的IP地址
- 20. 從Windows Phone發送電子郵件到特定地址8
- 21. windows phone 8上的Google地圖
- 22. Windows Phone上的本地數據庫8
- 23. Windows Phone 8
- 24. Windows Phone 8 ScrollViewer
- 25. MediaPlaybackControls Windows Phone 8
- 26. Windows Phone 8 TextBlock
- 27. Windows Phone 8 System.Reflection.TargetInvocationException
- 28. IsolatedStorage Windows phone 8
- 29. Popup Windows phone 8
- 30. Windows phone 8 XMLParseException
ip地址和GetHostNames劑量不存在於Windows手機SDK –