vb.net获取字典键值 c#获取字典中指定键所对应的值

vb.net怎样读取并更改指定注册表目录下的REG_SZ键值

VB.NET 参考代码:

创新互联公司-专业网站定制、快速模板网站建设、高性价比梨树网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式梨树网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖梨树地区。费用合理售后完善,十多年实体公司更值得信赖。

Imports Microsoft.Win32

Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim regKey As RegistryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Control\Windows", False)

For Each strSubKeyName In regKey.GetValueNames()

If regKey.GetValueKind(strSubKeyName) = RegistryValueKind.String Then

MessageBox.Show(regKey.GetValue(strSubKeyName))

' regKey.SetValue(strSubKeyName, "修改后的值")

End If

Next

End Sub

End Class

vb中如何获得键盘方向键的键值

将窗体KeyPreview属性设置为True并对Form_KeyDown事件编程,可以获取键盘箭头键的键值。实现方法如下:

Option Explicit

Private Sub Form_Load()

'允许窗体拦截键盘按键

Me.KeyPreview = True

End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

' KeyCode 键盘码是键盘上每个按键的唯一编码

' 在VB中,符号常数表示键盘码,例如 vbKeyF1 表示F1键,

' vbKeyHome 表示HOME键…… 

Select Case KeyCode

Case vbKeyLeft:     Print "左箭头键值:" + CStr(KeyCode)

Case vbKeyRight:    Print "右箭头键值:" + CStr(KeyCode)

Case vbKeyUp:       Print "上箭头键值:" + CStr(KeyCode)

Case vbKeyDown:     Print "下箭头键值:" + CStr(KeyCode)

End Select

End Sub

VB.net 中如何获取键盘输入的ASCii码

Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress

If Asc(0) Then

textbox1.text="0"

end if

end sub

vb获取注册表键值模块?

从一个VB编写的注册表程序中整理出来的,功能是获取注册表指定键值,内含注释,模块可用于注册表的操作中:

01

Function GetRegistryValue(ByVal hKey As RootKeyEnum, ByVal KeyName As String, _

02

ByVal ValueName As String, Optional DefaultValue As Variant) As Variant

03

Dim handle As Long

04

Dim resLong As Long

05

Dim resString As String

06

Dim resBinary() As Byte

07

Dim length As Long

08

Dim retVal As Long

09

Dim valueType As Long

10

Const KEY_READ = H20019

11

'// 默认结果

12

GetRegistryValue = IIf(IsMissing(DefaultValue), Empty, DefaultValue)

13

'// 打开键, 不存在则退出

14

If RegOpenKeyEx(hKey, KeyName, 0, KEY_READ, handle) Then Exit Function

15

'// 准备 1K resBinary 用于接收

16

length = 1024

17

ReDim resBinary(0 To length - 1) As Byte

18

'// 读注册表值

19

retVal = RegQueryValueEx(handle, ValueName, 0, valueType, resBinary(0), length)

20

'// 若resBinary 太小则重读

21

If retVal = ERROR_MORE_DATA Then

22

'// resBinary放大,且重新读取

23

ReDim resBinary(0 To length - 1) As Byte

24

retVal = RegQueryValueEx(handle, ValueName, 0, valueType, resBinary(0), _

25

length)

26

End If

27

'// 返回相应值类型

28

Select Case valueType

29

Case REG_DWORD, REG_DWORD_LITTLE_ENDIAN

30

'// REG_DWORD 和 REG_DWORD_LITTLE_ENDIAN 相同

31

CopyMemory resLong, resBinary(0), 4

32

GetRegistryValue = resLong

33

Case REG_DWORD_BIG_ENDIAN

34

'// Big Endian's 用在非-Windows环境, 如Unix系统, 本地计算机远程访问

35

CopyMemory resLong, resBinary(0), 4

36

GetRegistryValue = SwapEndian(resLong)

37

Case REG_SZ, REG_EXPAND_SZ

38

resString = Space$(length - 1)

39

CopyMemory ByVal resString, resBinary(0), length - 1

40

If valueType = REG_EXPAND_SZ Then

41

'// 查询对应的环境变量

42

GetRegistryValue = ExpandEnvStr(resString)

43

Else

44

GetRegistryValue = resString

45

End If

46

Case REG_MULTI_SZ

47

'// 复制时需指定2个空格符

48

resString = Space$(length - 2)

49

CopyMemory ByVal resString, resBinary(0), length - 2

50

GetRegistryValue = resString

51

Case Else ' 包含 REG_BINARY

52

'// resBinary 调整

53

If length UBound(resBinary) + 1 Then

54

ReDim Preserve resBinary(0 To length - 1) As Byte

55

End If

56

GetRegistryValue = resBinary()

57

End Select

58

'// 关闭注册表


分享题目:vb.net获取字典键值 c#获取字典中指定键所对应的值
浏览路径:http://myzitong.com/article/hijojs.html