这个我当然清楚了呵呵 我想是做JAVA还是做。NET
解决方案 »
- 项目部署如何设置文件权限
- Gridview 动态添加 CHECKBOX 问题(不要显示TRUE/FALSE)
- 断开式数据库连接 datagridview如何把修改的数据写入dataset中
- WPF listview 前后台数据绑定问题
- 在自定义安装类中重载Install(System.Collections.IDictionary stateSaver)加入base.Rollback(stateSaver)怎么会错误啊。。。
- c# 如何判断网址是否为有效的网址
- 如何安装windows服务?
- C#真的严谨吗?
- string 简单问题,急,急!在线
- 关于MSDN的疑问,请各位指教
- 菜鸟问题?
- VS.net的应用实例在什么地方
using System.Management; namespace ArLi.CommonPrj {
public class ChangeIP { ///
/// Build of ArLi 2003.6.3
///
public static readonly System.Version myVersion = new System.Version(1,1); private ManagementBaseObject iObj = null;
private ManagementBaseObject oObj = null;
private ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
private readonly ManagementObjectCollection moc; ///
/// example:
///
/// ArLi.CommonPrj.ChangeIP o = new ArLi.CommonPrj.ChangeIP();
/// string[] ipList = new string[]{"192.168.0.253","192.168.0.250"};
/// string[] subnetList = new string[]{"255.255.255.0","255.255.255.0"};
/// o.ChangeTo(ipList,subnetList);
///
///
public ChangeIP(){
moc = mc.GetInstances();
} /// cortrol
/// IPAddr List
/// subnetMask List
public void ChangeTo(string[] ipAddr,string[] subnetMask) {
foreach(ManagementObject mo in moc) {
if(! (bool) mo["IPEnabled"]) continue; iObj = mo.GetMethodParameters( "EnableStatic" );
iObj["IPAddress"] = ipAddr;
iObj["SubnetMask"] = subnetMask;
oObj = mo.InvokeMethod("EnableStatic", iObj, null);
}
} /// cortrol
/// IPAddr List
/// subnetMask List
/// gateway List
/// gateway CostMetric List, example: 1
public void ChangeTo(string[] ipAddr, string[] subnetMask, string[] gateways, string[] gatewayCostMetric) {
foreach(ManagementObject mo in moc) {
if(! (bool) mo["IPEnabled"]) continue; iObj = mo.GetMethodParameters("EnableStatic");
iObj["IPAddress"] = ipAddr;
iObj["SubnetMask"] = subnetMask;
oObj = mo.InvokeMethod("EnableStatic", iObj, null); iObj = mo.GetMethodParameters("SetGateways");
iObj["DefaultIPGateway"] = gateways;
iObj["GatewayCostMetric"] = gatewayCostMetric;
oObj = mo.InvokeMethod("SetGateways", iObj, null);
}
} /// cortrol
/// IPAddr List
/// subnetMask List
/// gateway List
/// gateway CostMetric List, example: 1
/// DNSServer List
public void ChangeTo(string[] ipAddr, string[] subnetMask, string[] gateways, string[] gatewayCostMetric, string[] dnsServer) {
foreach(ManagementObject mo in moc) {
if(! (bool) mo["IPEnabled"]) continue; iObj = mo.GetMethodParameters("EnableStatic");
iObj["IPAddress"] = ipAddr;
iObj["SubnetMask"] = subnetMask;
oObj = mo.InvokeMethod("EnableStatic", iObj, null); iObj = mo.GetMethodParameters("SetGateways");
iObj["DefaultIPGateway"] = gateways;
iObj["GatewayCostMetric"] = gatewayCostMetric;
oObj = mo.InvokeMethod("SetGateways", iObj, null); iObj = mo.GetMethodParameters("SetDNSServerSearchOrder");
iObj["DNSServerSearchOrder"] = dnsServer;
oObj = mo.InvokeMethod("SetDNSServerSearchOrder", iObj, null);
}
} /// DHCPEnabled
public void EnableDHCP() {
foreach(ManagementObject mo in moc) {
if(! (bool) mo["IPEnabled"]) continue; if(! (bool)mo["DHCPEnabled"]) {
iObj = mo.GetMethodParameters("EnableDHCP");
oObj = mo.InvokeMethod("EnableDHCP", iObj, null);
}
}
}
}
}
如果实在不行再问 至少你的让别知道你是思考过的 别一有问题就问
1、自己动手查找MSDN Library/SDK等官方文档
2、上网google查找别人写就的文章
3、自己多动动脑筋总结一下可能的解决方案
4、带着自己的想法去问身边有经验的同事或者朋友
5、到技术论坛上发贴提问,共同讨论一定要自己先动动脑子,有了自己的想法再去提问寻求帮助
查一下MSDN
查一下CSDN
问一下QQ上的
没人可问了,从网上搜索关键字 看别人的文章
ding