最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
在.NET中得到计算机硬件信息的一些功能
时间:2022-07-02 11:36:23 编辑:袖梨 来源:一聚教程网
在.NET中得到计算机硬件信息的一些功能
得到显示器分辨率
Dim X As Short = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
Dim Y As Short = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
MsgBox("您的显示器分辨率是:" & X & " X " & Y)
得到特殊文件夹的路径
'"Desktop"桌面文件夹路径
MsgBox(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))
'"Favorites"收藏夹路径
MsgBox(Environment.GetFolderPath(Environment.SpecialFolder.Favorites))
'"Application Data"路径
MsgBox(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))
'通用写法
'Dim SPEC As String = Environment.GetFolderPath(Environment.SpecialFolder.XXXXXXX)
'XXXXXXX是特殊文件夹的名字
得到操作系统版本信息
MsgBox(Environment.OSVersion.ToString)
得到当前登录的用户名
MsgBox(Environment.UserName)
得到当前应用程序的路径
MsgBox(Environment.CurrentDirectory)
打开和关闭CD-ROM
'先新建模块
Module mciAPIModule
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
(ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
End Module
'打开CD-ROM
Dim lRet As Long
lRet = mciSendString("set cdAudio door open", 0&, 0, 0)
'关闭CD-ROM
Dim lRet As Long
lRet = mciSendString("set cdAudio door Closed", 0&, 0, 0)
得到计算机IP和计算机全名
Dim MYIP As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName)
得到显示器分辨率
Dim X As Short = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
Dim Y As Short = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
MsgBox("您的显示器分辨率是:" & X & " X " & Y)
得到特殊文件夹的路径
'"Desktop"桌面文件夹路径
MsgBox(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))
'"Favorites"收藏夹路径
MsgBox(Environment.GetFolderPath(Environment.SpecialFolder.Favorites))
'"Application Data"路径
MsgBox(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))
'通用写法
'Dim SPEC As String = Environment.GetFolderPath(Environment.SpecialFolder.XXXXXXX)
'XXXXXXX是特殊文件夹的名字
得到操作系统版本信息
MsgBox(Environment.OSVersion.ToString)
得到当前登录的用户名
MsgBox(Environment.UserName)
得到当前应用程序的路径
MsgBox(Environment.CurrentDirectory)
打开和关闭CD-ROM
'先新建模块
Module mciAPIModule
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
(ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
End Module
'打开CD-ROM
Dim lRet As Long
lRet = mciSendString("set cdAudio door open", 0&, 0, 0)
'关闭CD-ROM
Dim lRet As Long
lRet = mciSendString("set cdAudio door Closed", 0&, 0, 0)
得到计算机IP和计算机全名
Dim MYIP As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName)
相关文章
- 人们熟悉的寄居蟹属于以下哪种分类 神奇海洋11月21日答案 11-21
- 第五人格11.22共研服有什么更新 11月22日共研服更新内容介绍 11-21
- 原神恰斯卡怎么培养 11-21
- 无期迷途四星装束是谁 11-21
- 王者荣耀帝丹高中校服怎么获得 11-21
- 光遇姆明季后续版本怎么玩 11-21