国产探花免费观看_亚洲丰满少妇自慰呻吟_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.



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 达州市| 东城区| 嵊州市| 康乐县| 抚远县| 乌海市| 中方县| 旌德县| 云安县| 治多县| 建始县| 阳春市| 新兴县| 四平市| 濮阳县| 贵州省| 菏泽市| 云林县| 湖南省| 泸水县| 开化县| 平阴县| 高密市| 淮北市| 武穴市| 衡山县| 恩平市| 肥城市| 乾安县| 苏州市| 邳州市| 张北县| 崇信县| 扎囊县| 溧水县| 安化县| 绩溪县| 卓资县| 黄浦区| 城口县| 云南省|