本文整理汇总了C#中Shell.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# Shell.Execute方法的具体用法?C# Shell.Execute怎么用?C# Shell.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shell
的用法示例。
在下文中一共展示了Shell.Execute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetIPInfoFromShell
private static IPInfo GetIPInfoFromShell()
{
// Get Ip Info from Shell
IPInfo IP;
Shell Shell = new Shell() { };
switch (OS.Type)
{
case OSType.Windows:
Shell.Command = "ipconfig";
Shell.Pattern = @"IPv4.*: (?<ip>.*)\r\n.*: (?<net>.*)\r\n.*: (?<gw>.*)\r\n";
break;
case OSType.Linux:
Shell.Command = "ifconfig";
Shell.Arguments = "eth0";
Shell.Pattern = @"inet\s(?<ip>.*)\snetmask\s(?<net>.*)\sbroadcast\s(?<gw>.*)";
break;
case OSType.MacOSX:
Shell.Command = "ifconfig";
Shell.Arguments = "en0";
Shell.Pattern = @"inet\s(?<ip>.*)\snetmask\s(?<net>.*)\sbroadcast\s(?<gw>.*)";
break;
default:
break;
}
if (Shell.Execute())
{
IP = new IPInfo(Shell.Values["ip"].Value, Shell.Values["net"].Value, Shell.Values["gw"].Value);
}
else
{
IP = new IPInfo();
}
IP.Source = IPsource.Shell;
IP.Shell = Shell;
return IP;
}