[Original] Accessing the registry in VB6.0

xiaoxiao2021-03-06  53

Author: bluesky35 (blue) 'The following statement is defined in the module: Declare Function RegCreateKey Lib "advapi32.dll" Alias ​​"RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As LongDeclare Function RegCloseKey Lib "advapi32. dll "(ByVal hKey As Long) As LongDeclare Function RegSetValueEx Lib" advapi32.dll "Alias" RegSetValueExA "(ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As LongPublic Const HKEY_CLASSES_ROOT = & H80000000Public Const HKEY_CURRENT_USER = & H80000001Public Const HKEY_LOCAL_MACHINE = & H80000002Public Const HKEY_USERS = & H80000003Public Const HKEY_PERFORMANCE_DATA = & H80000004Public Const HKEY_CURRENT_CONFIG = & H80000005Public Const HKEY_DYN_DATA = & H80000006Public Const REG_SZ = 1 & 'the following definitions in the FORM' write registry Private Sub Command1_click () DIM RET As Long, RTN As Long, HKEY As Long, HKEY2 AS STRING Entry As String, Value As String Entry = "EventMessageFile" Value = "C: /Winnt/MICROFT.NET/FR amework / v1.1.4322 / EventLogMessages.dll " 'create key-value ret = RegCreateKey (HKEY_LOCAL_MACHINE," SYSTEM / CurrentControlSet / Services / Eventlog / Eventlog2 / Eventlog2 ", hKey)' value written to If Not ret Then rtn = RegSetValueEx (hKey, Entry, 0, REG_SZ, BYVAL VALUE, LEN (VALUE)) IF NOT RTN THEN MSGBOX "WRITE SUCCESSED!" END IF 'Turn off RTN = Regclosekey (HKEY) Else Msgbox "Create Subkey Operation Fail" End IFEND SUB Finally, I wish you good luck.

转载请注明原文地址:https://www.9cbs.com/read-113850.html

New Post(0)