System.Environment類允許我們通過不同的靜態(tài)成員獲得大量的有關(guān)運行.net應(yīng)用程序的操作系統(tǒng)的細(xì)節(jié)。
創(chuàng)新互聯(lián)從2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元陽高做網(wǎng)站,已為上家服務(wù),為陽高各地企業(yè)和個人服務(wù),聯(lián)系電話:18980820575
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace 命令行參數(shù) { class Program { static int Main(string[] args) { //通過Environment.GetCommandLineArgs()獲取命令行參數(shù) //第一個索引為應(yīng)用程序本身名稱 //數(shù)組中其他元素包含單獨的命令行參數(shù) string[] theArg = Environment.GetCommandLineArgs(); foreach(string arg in theArg) { Console.WriteLine("Arg:{0}",arg); } ShowEnvironmentDetails(); Console.WriteLine("退出后"); //這一句不會執(zhí)行 return 0; } static void ShowEnvironmentDetails() { //從當(dāng)前進(jìn)程檢索所有環(huán)境變量名及其值 IDictionary environmentVariables = Environment.GetEnvironmentVariables(); foreach (DictionaryEntry de in environmentVariables) { Console.WriteLine("{0}----{1}",de.Key,de.Value); } Console.WriteLine("--------------------------------------"); //返回包含當(dāng)前計算機(jī)中的邏輯驅(qū)動器名稱的字符串?dāng)?shù)組 Console.WriteLine("當(dāng)前電腦有{0}個邏輯驅(qū)動器",Environment.GetLogicalDrives().Length); foreach(string drive in Environment.GetLogicalDrives()) { Console.WriteLine("drive:{0}",drive); } //判斷當(dāng)前操作系統(tǒng)是否為64位操作系統(tǒng) Console.WriteLine("當(dāng)前系統(tǒng)為64位系統(tǒng):{0}",Environment.Is64BitOperatingSystem); //獲取本地計算機(jī)的NETBIOS名稱 Console.WriteLine("計算機(jī)的名稱為:{0}",Environment.MachineName); //獲取系統(tǒng)目錄的完全限定路徑 Console.WriteLine("系統(tǒng)目錄的完全限定路徑:{0}",Environment.SystemDirectory); //獲取當(dāng)前計算機(jī)上的處理器數(shù) Console.WriteLine("當(dāng)前計算機(jī)上的處理器數(shù)為:{0}",Environment.ProcessorCount); //獲取操作系統(tǒng)頁面文件的內(nèi)存量 Console.WriteLine("當(dāng)前操作系統(tǒng)頁面文件的內(nèi)存量為:{0}",Environment.SystemPageSize); //獲取系統(tǒng)啟動后經(jīng)過的毫秒數(shù) 自系統(tǒng)啟動以來到現(xiàn)在所經(jīng)過的時間 Console.WriteLine("系統(tǒng)啟動后經(jīng)過的毫秒數(shù):{0}",Environment.TickCount); //獲取當(dāng)前已登錄到windows操作系統(tǒng)的人員的用戶名 Console.WriteLine("當(dāng)前登錄操作系統(tǒng)的用戶名為:{0}",Environment.UserName); //獲取包含當(dāng)前平臺標(biāo)識符和版本號的 operatingSystem對象 Console.WriteLine("當(dāng)前操作系統(tǒng)為:{0}",Environment.OSVersion); //獲取一個Version對象,該對象描述公共語言運行時的主版本、此版本、內(nèi)部版本和修訂號 Console.WriteLine(".NET Version:{0}",Environment.Version); Console.ReadLine(); //程序結(jié)束 終止此進(jìn)程并為基礎(chǔ)操作系統(tǒng)提供指定的退出代碼 Environment.Exit(-1); Console.WriteLine("退出"); //這一句也不會被執(zhí)行 } } }
要想了解更多System.Environment類的成員,請查閱msdn。
新聞名稱:C#.NETSystem.Environment類獲取系統(tǒng)屬性
瀏覽地址:http://chinadenli.net/article20/geopco.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)、品牌網(wǎng)站設(shè)計、企業(yè)建站、靜態(tài)網(wǎng)站、響應(yīng)式網(wǎng)站、品牌網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)