Professional Documents
Culture Documents
Write A Binary Value To The Registry
Write A Binary Value To The Registry
Instructions: Copy the declarations and code below and paste directly into your VB project.
Declarations:
Option Explicit
Private
'WRITES Declare Function
A BINARY VALUERegCreateKey
TO REGISTRY:Lib _
"advapi32.dll" Alias "RegCreateKeyA" _
'PARAMETERS:
(ByVal Hkey As Long, ByVal lpSubKey As _
String,
'Hkey: phkResult
Top Level Key AsasLong) As Long
defined by
'REG_TOPLEVEL_KEYS Enum (See Declarations)
Private Declare Function RegCloseKey Lib _
"advapi32.dll"
'strPath (ByVal
- 'Full Path Hkey As Long) As Long
of Subkey
'if path does not exist it will be created
Private Declare Function RegSetValueEx Lib _
"advapi32.dll"
'strValue Alias "RegSetValueExA" _
ValueName
(ByVal Hkey As Long, ByVal _
lpValueName
'binData - Value As String, ByVal _
Data
Reserved As Long, ByVal dwType _
As Long,
'Returns: lpData
True As Any, ByVal
if successful, false _otherwise
cbData As Long) As Long
'EXAMPLE
Private
'Dim Const
v As REG_BINARY = 3
Variant
No Text Boxes
'Open "C:\myword.doc" For Binary As #1
'v = Input(LOF(1), #1)
About
'Close #1 Legal Awards Contact Privacy Advertise
'WriteBinaryToRegistry(HKEY_LOCAL_MACHINE, _
"Software\MySofware", "My Binary Data", v)
WriteBinaryToRegistry = (r = 0)