C#_windows版本判断+启用禁用本地连接+修改mac地址

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
using System.ServiceProcess;
namespace ReworkMAC
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
{
if (vs.Major >= 4 && vs.Minor > 0)
{
if (vs.Minor < 90)
{
this._osID = SystemOS.Win98;
int _majorVersion;
int _minorVersion;
int _revision;
int _buildNumber;
string _versionNumber;
SystemOS _osID;
}
else
{
this._osID = SystemOS.WinME;
}
}
else
{
this._osID = SystemOS.Win95;
}
}
else if (os.Platform == PlatformID.Win32S)
}
private void Form1_Load(object sender, EventArgs e)
{
listBox1.Items.Clear();
RegistryKey macRegistry = Registry.LocalMachine.OpenSubKey("SYSTEM").OpenSubKey("CurrentControlSet").OpenSubKey("Control").OpenSubKey("Class").OpenSubKey("{4D36E972-E325-11CE-BFC1-08002bE10318}");//mac的注册表建所在
}
/////////////////////////////////////////////////////////////////
///一下这一段有待以后研究,现在还没有看懂
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
public void GetOsVersion()
{
OperatingSystem os = Environment.OSVersion;
Version vs = os.Version;
this._majorVersion = vs.Major;
this._minorVersion = vs.Minor;
this._revision = vs.Revision;
this._buildNumber = vs.Build;
this._versionNumber = this._majorVersion.ToString() + ":" +
continue;
string[] addresses = (string[])mo["IPAddress"];
string[] subnets = (string[])mo["IPSubnet"];
this._minorVersion.ToString() + ":" + this._revision.ToString() + ":" + this._buildNumber.ToString();
if (os.Platform == PlatformID.Win32NT && vs.Major == 5)
WinVista = 8,
Win7 = 9
}
这些都写完了,我要做什么,明白了吧.
语言c# ,运行需要 .Net Framework 2.0
在很多行业或公司,会通过限制ip的方法,使局域网内一部分ip可以上外网。本方案通过修改ip和网卡地址达到在别人不知不觉地情况下共用一个ip上网。
else if (os.Platform == PlatformID.Win32NT && vs.Major <= 4)
{
this._osID = SystemOS.WinNT;
}
else if (os.Platform == PlatformID.Win32Windows)
textBox3.Text = adapter.GetPhysicalAddress().ToString();
textBox10.Text = adapter.Id;
}
// listBox3.Items.Add(adapter.Id+" 接口类型 "+workInterfaceType.ToString());
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Windows;
using System.Management;
using workInformation;
}
//////////////////////////////////////////////////////////////
// checkBox2.
foreach (NetworkInterface adapter in nics)
{
if (=="本地连接")
{
textBox2.Text = adapter.Description;
/// <summary>
///Define different Operating Systems
/// </summary>
public enum SystemOS
{
WinErr = 0, //Error
{
if (vs.Minor > 0) { this._osID = SystemOS.WinXP; }
else { this._osID = SystemOS.Win2K; }
}
else if (os.Platform == PlatformID.Win32NT && vs.Major == 6)
{
if (vs.Minor > 0) { this._osID = SystemOS.Win7; }
else { this._osID = SystemOS.WinVista; }
}
==================代码如下: =======================
using System;
using System.Collections.Generic;
using ponentModel;
using System.Data;
using System.Drawing;
{
this._osID = SystemOS.Win32s;
}
} Leabharlann //---------------------------------------------------------------------------------------------------
Win95 = 1,
Win98 = 2,
WinME = 3,
WinNT = 4,
Win2K = 5,
WinXP = 6,
Win32s = 7,
textBox4.Text = computerProperties.HostName;
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (string mrk in macRegistry.GetSubKeyNames())
{
listBox1.Items.Add(mrk);
}
IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if (!(bool)mo["IPEnabled"])
foreach (string sad in addresses)
textBox7.Text = sad;
foreach (string sub in subnets)
textBox8.Text = sub;
相关文档
最新文档