Так... А я не понял! Ответ-то будет???
Господин GSerg!!! Куда вы пропали???
Option Explicit
Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" _
(ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, _
ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, _
lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition As Long) As Long
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _
lpType As Long, lpData As Any, lpcbData As Long) As Long
Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, _
ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Public Const ERROR_SUCCESS As Long = 0
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_CONFIG = &H80000005
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_DYN_DATA = &H80000006
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const REG_OPTION_NON_VOLATILE = 0 ' Key is preserved when system is rebooted
Public Const KEY_ALL_ACCESS = 983103
Public Const REG_BINARY = 3 ' Free form binary
Public Sub Main()
Dim iKey As Long, mByteArr() As Byte, s As String, ss As String, i As Long
If ERROR_SUCCESS = RegOpenKey(HKEY_LOCAL_MACHINE, _
"SYSTEM\CurrentControlSet\Control\TimeZoneInformation", iKey) Then
If RegQueryByteValue(iKey, "StandardStart", mByteArr) Then
For i = 0 To UBound(mByteArr)
s = IIf(mByteArr(i) >= 16, vbNullString, "0") & Hex(mByteArr(i))
ss = ss & " " & s
Next i
Debug.Print "StandardStart: " & ss
End If
RegCloseKey iKey
End If
If ERROR_SUCCESS = RegCreateKeyEx(HKEY_CURRENT_USER, _
"Software\VB and VBA Program Settings\_Test", 0, "", _
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, ByVal 0, iKey, 0) Then
RegSetValueEx iKey, "StandardStart", 0, REG_BINARY, mByteArr(0), UBound(mByteArr) + 1
End If
End Sub
Public Function RegQueryByteValue(ByVal hKey As Long, ByVal strValueName As String, mByteArr() As Byte) As Boolean
Const REG_SZ = 1
Dim ByteArr() As Byte
Dim lResult As Long, lValueType As Long, strBuf As String, lDataBufSize As Long
'retrieve nformation about the key
lResult = RegQueryValueEx(hKey, strValueName, 0, lValueType, ByVal 0, lDataBufSize)
If lResult = 0 Then
If lValueType = REG_BINARY Then
'Create a buffer
ReDim ByteArr(lDataBufSize - 1)
'retrieve the key's content
lResult = RegQueryValueEx(hKey, strValueName, 0, 0, ByteArr(0), lDataBufSize)
If lResult = 0 Then
'Remove the unnecessary chr$(0)'s
mByteArr = ByteArr
RegQueryByteValue = True
End If
End If
End If
End Function
Сейчас этот форум просматривают: Yandex-бот и гости: 125