vb查詢登錄檔鍵值

2021-07-04 03:14:26 字數 1928 閱讀 5349

option explicit

private declare function regqueryvalueex lib "advapi32.dll" alias "regqueryvalueexa" (byval hkey as long, byval lpvaluename as string, byval lpreserved as long, byref lptype as long, byref lpdata as any, byref lpcbdata as long) as long

private declare function regopenkey lib "advapi32.dll" alias "regopenkeya" (byval hkey as long, byval lpsubkey as string, byref phkresult as long) as long

private declare function regclosekey lib "advapi32.dll" (byval hkey as long) as long

private const hkey_local_machine as long = &h80000002

part1

stm32 virtual com port所在的登錄檔位址。

private sub command3_click()

dim hkey as long, ret as long, name as string, idx as long

dim tempname as string

name = string(256, chr(0))

ret = regopenkey(hkey_local_machine, "system\currentcontrolset\enum\usb\vid_0483&pid_5740\demo_1.000", hkey) '引號內容為目標登錄檔位址

if ret = 0 then

ret = regqueryvalueex(hkey, "devicedesc", 0, 1, byval name, len(name))

regclosekey hkey

msgbox name

else

msgbox "沒有這個項"

end if

text1.text = name

combo1.text = name'這裡可以讓combo顯示stm32

end sub

'hkey_local_machine\system\currentcontrolset\enum\usb\vid_0483&pid_5740\demo_1.000

part2

com口所在的位址。

注:會因為usb拔插而消失/存在。

private sub command4_click()

dim hkey as long, ret as long, name as string, idx as long

dim tempname as string

name = string(256, chr(0))

ret = regopenkey(hkey_local_machine, "hardware\devicemap\serialcomm", hkey)

if ret = 0 then

ret = regqueryvalueex(hkey, "\device\usbser000", 0, 1, byval name, len(name))

regclosekey hkey

msgbox name

else

msgbox "沒有這個項"

end if

combo1.text = name '這裡可以讓combo顯示com

end sub

核心查詢登錄檔鍵值

include void driverunload in pdriver object driverobject boolean querykeyinfo pcwstr path,pcwstr name rtlinitunicodestring keyname,name 要查詢的鍵值名字 試探性,返...

登錄檔鍵值

登錄檔鍵值 windows系統登錄檔項,通過編輯和修改可以改變或優化windows作業系統相關功能和效能。登錄檔概述 編輯 登錄檔 registry 正體中文版windows作業系統稱為登入 是微軟公司從windows 95作業系統開始 至目前最新windows 10作業系統依然使用的是它 引入用於...

DOS獲取登錄檔鍵值

例子 echo off for f delims i in reg.exe query hkey local machine software ut utscada v installdirectory do set installdir i set installdir installdir 35...