|
помогите!!
#32401838
Ссылка:
Ссылка на сообщение:
Ссылка с названием темы:
|
|
|
|
С помощью VB можно изменить значение в реестре
Вот пример кода, для изменения значения:
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96.
'RootKeys
Public Enum EnmRootKeys
HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_USER = &H80000001
HKEY_LOCAL_MACHINE = &H80000002
HKEY_USERS = &H80000003
HKEY_PERFORMANCE_DATA = &H80000004
HKEY_CURRENT_CONFIG = &H80000005
HKEY_DYN_DATA = &H80000006
End Enum
'Key creation/open disposition
Private Enum EnmCreateOpenMode
REG_CREATED_NEW_KEY = &H1
REG_OPENED_EXISTING_KEY = &H2
End Enum
Private Const RESERVED_VALUE As Long = 0
'Open/Create Options
Private Enum EnmCreateOptions
REG_OPTION_NON_VOLATILE = 0&
REG_OPTION_VOLATILE = &H1
End Enum
'Registry Specific Access Rights
Private Enum EnmAccessRights
KEY_QUERY_VALUE = &H1
KEY_SET_VALUE = &H2
KEY_CREATE_SUB_KEY = &H4
KEY_ENUMERATE_SUB_KEYS = &H8
KEY_NOTIFY = &H10
KEY_CREATE_LINK = &H20
KEY_ALL_ACCESS = &H3F
End Enum
'Predefined Value Types
Public Enum EnmValueTypes
REG_NONE = (0) 'No value type
REG_SZ = ( 1 ) 'Unicode nul terminated string
REG_EXPAND_SZ = (2) 'Unicode nul terminated string w/enviornment var
REG_BINARY = ( 3 ) 'Free form binary
REG_DWORD = (4) '32-bit number
REG_DWORD_LITTLE_ENDIAN = ( 4 ) '32-bit number (same as REG_DWORD)
REG_DWORD_BIG_ENDIAN = (5) '32-bit number
REG_LINK = ( 6 ) 'Symbolic Link (unicode)
REG_MULTI_SZ = (7) 'Multiple Unicode strings
REG_RESOURCE_LIST = ( 8 ) 'Resource list in the resource map
REG_FULL_RESOURCE_DESCRIPTOR = (9) 'Resource list in the hardware description
REG_RESOURCE_REQUIREMENTS_LIST = ( 10 )
End Enum
'Structures Needed For Registry Prototypes
Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Boolean
End Type
'Define severity codes
Private Const ERROR_SUCCESS = 0 &
Private Const ERROR_ACCESS_DENIED = 5
Private Const ERROR_NO_MORE_ITEMS = 259
Public Function SetRegValue(hKey As EnmRootKeys, KeyName As String, _
ParamName As String, ParamValue As String) As Boolean
Dim OpenedKeyHandle As Long
Dim SetResult As Long
Dim OpenCreateModeResult As EnmCreateOpenMode
Dim tmpClass As String
Dim tmpSecureAttrib As SECURITY_ATTRIBUTES
On Error GoTo ERROR_HANDLER
RegCreateKeyEx hKey, KeyName, RESERVED_VALUE, tmpClass, REG_OPTION_NON_VOLATILE, _
KEY_ALL_ACCESS, tmpSecureAttrib, OpenedKeyHandle, OpenCreateModeResult
'Set the value
SetResult = RegSetValueEx(OpenedKeyHandle, ParamName, RESERVED_VALUE, REG_SZ, ParamValue, _
Len(ParamValue))
'Close the key
RegCloseKey OpenedKeyHandle
'Return obtained value
If SetResult = ERROR_SUCCESS Then
SetRegValue = True
Exit Function
End If
ERROR_HANDLER:
SetRegValue = False
If DisplayRegErrMsg Then
If Err <> 0 Then
MsgBox "ERROR #" & Str$(Err.Number) & " : " & Err.Description, vbInformation, "CSN "
Else
MsgBox "ERROR #" & Str$(SetResult) & " : Can't set registry value ", vbInformation, " CSN "
End If
End If
End Function
|
|
|