diff --git a/IPAddrTest/IPAddrTest.cs b/IPAddrTest/IPAddrTest.cs
new file mode 100644
index 0000000..2e9f3ca
--- /dev/null
+++ b/IPAddrTest/IPAddrTest.cs
@@ -0,0 +1,42 @@
+using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System.Net.NetworkInformation;
+using System.Linq;
+using System.Net.Sockets;
+
+namespace IPAddrTest
+{
+ [TestClass]
+ public class IPAddrTest
+ {
+ [TestMethod]
+ public void GetIPAndInterfaceNameTest()
+ {
+ foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
+ {
+ if (ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211
+ || ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet
+ )
+ {
+ Console.WriteLine(ni.Name);
+ foreach (UnicastIPAddressInformation ip in ni.GetIPProperties().UnicastAddresses)
+ {
+ if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
+ {
+ Console.WriteLine(ip.Address.ToString());
+ }
+ }
+ }
+ }
+
+
+ var address = NetworkInterface.GetAllNetworkInterfaces()
+ .Where(i => i.NetworkInterfaceType == NetworkInterfaceType.Wireless80211
+ ||i.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
+ .SelectMany(i => i.GetIPProperties().UnicastAddresses)
+ .Where(a => a.Address.AddressFamily == AddressFamily.InterNetwork)
+ .Select(a => a.Address.ToString())
+ .ToList();
+ }
+ }
+}
diff --git a/IPAddrTest/IPAddrTest.csproj b/IPAddrTest/IPAddrTest.csproj
new file mode 100644
index 0000000..3206a35
--- /dev/null
+++ b/IPAddrTest/IPAddrTest.csproj
@@ -0,0 +1,90 @@
+
+
+
+ Debug
+ AnyCPU
+ {29B877FF-6E10-4F2D-BC86-3782714192C1}
+ Library
+ Properties
+ IPAddrTest
+ IPAddrTest
+ v4.5.2
+ 512
+ {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 10.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+ $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
+ False
+ UnitTest
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {cb033971-3534-488d-86aa-fc0f05456908}
+ Wox.Plugin.IPAddress
+
+
+
+
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/IPAddrTest/Properties/AssemblyInfo.cs b/IPAddrTest/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..5c6e88a
--- /dev/null
+++ b/IPAddrTest/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("IPAddrTest")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("IPAddrTest")]
+[assembly: AssemblyCopyright("Copyright © 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+//将 ComVisible 设置为 false 将使此程序集中的类型
+//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("29b877ff-6e10-4f2d-bc86-3782714192c1")]
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Wox.Plugin.IPAddress.sln b/Wox.Plugin.IPAddress.sln
index 08ef4ef..7c18746 100644
--- a/Wox.Plugin.IPAddress.sln
+++ b/Wox.Plugin.IPAddress.sln
@@ -1,10 +1,12 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.21005.1
+# Visual Studio 15
+VisualStudioVersion = 15.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.IPAddress", "Wox.Plugin.IPAddress\Wox.Plugin.IPAddress.csproj", "{CB033971-3534-488D-86AA-FC0F05456908}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IPAddrTest", "IPAddrTest\IPAddrTest.csproj", "{29B877FF-6E10-4F2D-BC86-3782714192C1}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
{CB033971-3534-488D-86AA-FC0F05456908}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB033971-3534-488D-86AA-FC0F05456908}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB033971-3534-488D-86AA-FC0F05456908}.Release|Any CPU.Build.0 = Release|Any CPU
+ {29B877FF-6E10-4F2D-BC86-3782714192C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {29B877FF-6E10-4F2D-BC86-3782714192C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {29B877FF-6E10-4F2D-BC86-3782714192C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {29B877FF-6E10-4F2D-BC86-3782714192C1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Wox.Plugin.IPAddress/IPAddress.cs b/Wox.Plugin.IPAddress/IPAddress.cs
index 355d7af..18d874b 100644
--- a/Wox.Plugin.IPAddress/IPAddress.cs
+++ b/Wox.Plugin.IPAddress/IPAddress.cs
@@ -1,8 +1,6 @@
using System;
using System.Windows.Forms;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
using System.Net;
using System.Net.NetworkInformation;
@@ -13,25 +11,42 @@ public class Program : IPlugin
public void Init(PluginInitContext context) { }
public List Query(Query query)
{
- List results = new List();
+ var results = new List();
- String hostname = Dns.GetHostName();
-
- // Get the Local IP Address
- String IP = Dns.GetHostByName(hostname).AddressList[0].ToString();
+ var hostname = Dns.GetHostName();
// Get the External IP Address
- String externalip = new WebClient().DownloadString("http://ipecho.net/plain");
- String icon = "ipaddress.png";
- results.Add(Result(IP, "Local IP Address ", icon, Action(IP)));
+ const string icon = "ipaddress.png";
+ foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
+ {
+ if (ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211
+ || ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
+ {
+ //Console.WriteLine(ni.Name);
+ foreach (UnicastIPAddressInformation ip in ni.GetIPProperties().UnicastAddresses)
+ {
+ if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
+ {
+ //Console.WriteLine(ip.Address.ToString());
+ results.Add(
+ Result(ip.Address.ToString(),
+ ni.Name,
+ icon, Action(ip.Address.ToString())));
+ }
+ }
+ }
+ }
+
+
+ var externalip = new WebClient().DownloadString("http://ipecho.net/plain");
results.Add(Result(externalip, "External IP Address ", icon, Action(externalip)));
return results;
}
// relative path to your plugin directory
- private static Result Result(String title, String subtitle, String icon, Func action)
+ private static Result Result(string title, string subtitle, string icon, Func action)
{
return new Result()
{
@@ -43,7 +58,7 @@ private static Result Result(String title, String subtitle, String icon, Func Action(String text)
+ private static Func Action(string text)
{
return e =>
{
@@ -54,7 +69,7 @@ private static Func Action(String text)
};
}
- public static void CopyToClipboard(String text)
+ public static void CopyToClipboard(string text)
{
Clipboard.SetText(text);
}
diff --git a/Wox.Plugin.IPAddress/Ref/Wox.Plugin.dll b/Wox.Plugin.IPAddress/Ref/Wox.Plugin.dll
new file mode 100644
index 0000000..57403a1
Binary files /dev/null and b/Wox.Plugin.IPAddress/Ref/Wox.Plugin.dll differ
diff --git a/Wox.Plugin.IPAddress/Wox.Plugin.IPAddress.csproj b/Wox.Plugin.IPAddress/Wox.Plugin.IPAddress.csproj
index 7be3b1d..6160bb4 100644
--- a/Wox.Plugin.IPAddress/Wox.Plugin.IPAddress.csproj
+++ b/Wox.Plugin.IPAddress/Wox.Plugin.IPAddress.csproj
@@ -9,7 +9,7 @@
Properties
Wox.Plugin.IPAddress
Wox.Plugin.IPAddress
- v3.5
+ v4.5.2
512
@@ -21,6 +21,7 @@
DEBUG;TRACE
prompt
4
+ false
pdbonly
@@ -29,18 +30,19 @@
TRACE
prompt
4
+ false
+
- ..\..\Wox.Plugin.Template\packages\Wox.Plugin.1.1.1.426\lib\net35\Wox.Plugin.dll
- False
+ Ref\Wox.Plugin.dll