更改多個網卡與電腦名稱 程式畫面: 詳細程式碼如下: using System; using System.Management; // System.Management 命名空間 需加入參考System.Management using System.Runtime.InteropServices; using System.Text.RegularExpressions; // System.Collections 命名空間 using System.Windows.Forms; namespace SetIPAndHostName { public partial class Form1 : Form { ManagementObject objCls; // ManagementObject 類別 , 表示 WMI 執行個體。 string strCls = "Win32_NetworkAdapterConfiguration" ; // WMI 名稱空間 ( Namespace ) string strNS = "root\\CIMV2" ; // WMI 類別 (Class) string strIndex; // 用來記錄網路介面卡 Index [DllImport( "kernel32.dll" )] static extern bool SetComputerName ( string lpComputerName ) ; [DllImport( "kernel32.dll" )] static extern bool SetComputerNameEx ( _COMPUTER_NAME_FORMAT iType, string lpComputerName ) ; public Form1 ( ) { InitializeComponent(); } pr...
留言
張貼留言