- 在 [工具] 功能表中選取 [選項]。
- 在 [文字編輯器] 資料夾中,選擇 [所有語言] 子資料夾內之 [一般] 選項,將此選項設定為全域性。
-或-
在您用來進 行程式設計的語言子資料夾內選擇 [一般] 選項。 - 在 [ 顯示] 下,選取 [ 行號]。
2010年4月14日 星期三
顯示編輯器的行數
參考 http://msdn.microsoft.com/zh-tw/library/ms165340.aspx
獲得mac address
using System;
using System.Management;
class App
{
static string GetMAC()
{
using (ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration"))
{
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if ((bool)mo["IPEnabled"])
return mo["MacAddress"].ToString();
}
}
return null;
}
public static void Main()
{
SelectQuery query = new SelectQuery("Win32_ComputerSystem");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach (ManagementObject mo in searcher.Get())
{
Console.WriteLine("Mac Address : {0} ", GetMAC());
}
Console.ReadKey();
}
}
修改電腦工作群組
using System;
using System.Management;
class program
{
public static void Main()
{
string WorkgroupName = "ECLASS";
ManagementObject manage = new ManagementObject(string.Format("Win32_ComputerSystem.Name='{0}'", Environment.MachineName));
object[] args = { WorkgroupName, null, null, null };
manage.InvokeMethod("JoinDomainOrWorkgroup", args);
Console.WriteLine("Done! The Workgroup name will take effect after the next computer restart.");
Console.ReadKey();
}
}
修改電腦名稱
using System;
using System.Runtime.InteropServices;
class Program
{
enum _COMPUTER_NAME_FORMAT
{
ComputerNameNetBIOS,
ComputerNameDnsHostname,
ComputerNameDnsDomain,
ComputerNameDnsFullyQualified,
ComputerNamePhysicalNetBIOS,
ComputerNamePhysicalDnsHostname,
ComputerNamePhysicalDnsDomain,
ComputerNamePhysicalDnsFullyQualified,
ComputerNameMax
};
//_COMPUTER_NAME_FORMAT COMPUTER_NAME_FORMAT;
[DllImport("kernel32.dll")]
static extern bool SetComputerName(string lpComputerName);
[DllImport("kernel32.dll")]
static extern bool SetComputerNameEx(_COMPUTER_NAME_FORMAT iType, string lpComputerName);
public static void Main()
{
string MachineName = "winxp-vm";
bool succeeded = SetComputerName(MachineName);
bool succeeded2 = SetComputerNameEx(_COMPUTER_NAME_FORMAT.ComputerNamePhysicalDnsHostname, MachineName);
if (succeeded && succeeded2){
Console.WriteLine("Done! The name will take effect after the next computer restart.");
}
else
{
Console.WriteLine("Error!");
}
Console.ReadKey();
}
}
訂閱:
意見 (Atom)