1
我想在C#中编写一个程序,该程序可以识别现在连接到Internet的计算机,或者不通过C#。 你会帮我怎么做,我不知道它,因为我没有在C#中工作的网络。查找网络状态
还有一个问题,我如何从c#运行程序并发送参数?
我想在C#中编写一个程序,该程序可以识别现在连接到Internet的计算机,或者不通过C#。 你会帮我怎么做,我不知道它,因为我没有在C#中工作的网络。查找网络状态
还有一个问题,我如何从c#运行程序并发送参数?
使用微软的InternetGetConnectedState函数。
你可以用P/Invoke调用它:
using System;
using System.Runtime.InteropServices;
namespace ConnectionState
{
internal class Program
{
[DllImport("wininet.dll", SetLastError = true)]
private static extern bool InternetGetConnectedState(out int lpdwFlags, int dwReserved);
private static void Main(string[] args)
{
int flags;
bool isConnected = InternetGetConnectedState(out flags, 0);
Console.WriteLine(string.Format("Is connected: {0} Flags:{1}", isConnected, flags));
Console.Read();
}
}
}
回答问题#2:[调试在Visual Studio中的命令行参数(http://stackoverflow.com/q/298708/ 94928) – heavyd 2010-12-05 22:38:04