国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

Retrieving Environmental Details using VB.NET

2024-07-10 13:08:01
字體:
來源:轉載
供稿:網友
注冊會員,創建你的web開發資料庫,windows based application would generally have requirement to access the windows system directory path, current directory , windows directory or to retrieve the current computer name,username, domainname, osversion etc. retrieving these information required api calls in vb6.

vb.net removes the complexity of calling api to access such useful information by providing the class library environment as part of .net. as known to all of us, the class library is accessible to all the .net languages.

here is an example that retrieves the above information using vb.net.

1) place a button in the form
2) place a textbox in the form and name it as txtinfo
3) set the multi-line property of the textbox(txtinfo) to true
4) import the system.environment namespace
5) write the following code in the commandbutton click event

        dim s as string
        dim o as system.environment

        s = "current directory=system.environment.currentdirectory()->"
        s = s & o.currentdirectory() & vbcrlf

        s = s & "commandline=system.environment.commandline()->"
        s = s & o.commandline() & vbcrlf

        s = s & "environment variable=system.environment.getenvironmentvariable(variable)->"
        s = s & o.getenvironmentvariable("path") & vbcrlf

        s = s & "machinename=system.environment.machinename->"
        s = s & o.machinename & vbcrlf

        s = s & "systemdirectory=system.environment.systemdirectory->"
        s = s & o.systemdirectory & vbcrlf

        s = s & "username=system.environment.username->"
        s = s & o.username & vbcrlf

        s = s & "userdomainname=system.environment.userdomainname->"
        s = s & o.userdomainname & vbcrlf

        s = s & "osversion=system.environment.osversion->"
        s = s & o.osversion.tostring & vbcrlf

  txtinfo.text = s

the namespace system.environment provides methods  to access various information like system name, domain name , username, osversion etc. these methods returns a string as a parameter. values are retrieved and stored in the local variable s. to avoid using a length qualifier system.environment with each call, a varaible is declared of type system.environment and the same is substituted there.

when the button is pressed, all the above information  are retrieved and posted in the textbox txtinfo.

happy programming with vb.net.



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 明光市| 张家界市| 成安县| 曲麻莱县| 五常市| 班戈县| 张家港市| 岳西县| 宁强县| 明光市| 上犹县| 罗山县| 随州市| 防城港市| 麻城市| 临颍县| 兴义市| 星子县| 北碚区| 临海市| 民和| 綦江县| 商洛市| 紫云| 诏安县| 名山县| 滦平县| 清流县| 偃师市| 潢川县| 白山市| 莒南县| 华安县| 汉沽区| 南宫市| 临沂市| 灵宝市| 江川县| 涪陵区| 平安县| 普洱|