Ребя помогите кто знает пожалуйста!!!
Вот по этой ссылке есть проетк http://www.vbnet.ru/samples/download.aspx?id=101
но как сделать так чтоб замисть "Change!" писало имя ключа(создаваемого\удаляемого) в реестре
Вот код:
----------------------------------------------
Public Enum ROOT_KEYS
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
Public Enum NOTIFY_EVENTS
REG_NOTIFY_CHANGE_NAME = &H1
REG_NOTIFY_CHANGE_ATTRIBUTES = &H2
REG_NOTIFY_CHANGE_LAST_SET = &H4
REG_NOTIFY_CHANGE_SECURITY = &H8
End Enum
Private Declare Function RegNotifyChangeKeyValue Lib "advapi32" (ByVal hKey As Long, ByVal bWatchSubTree As Boolean, ByVal dwNotifyFilter As Long, ByVal hEvent As Long, ByVal fAsynchronous As Boolean) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function CreateEvent Lib "kernel32" Alias "CreateEventA" (ByVal lpEventAttributes As Long, ByVal bManualReset As Long, ByVal bInitialState As Long, ByVal lpName As String) As Long
Private Declare Function ResetEvent Lib "kernel32" (ByVal hEvent As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const WAIT_ABANDONED = &H80
Private Const WAIT_FAILED = &HFFFFFFFF
Private Const WAIT_OBJECT_0 = &H0
Private Const WAIT_TIMEOUT = &H102&
Public hEvent As Long, bExit As Boolean
Public Sub RegMonitor(hKey As ROOT_KEYS, sRegKeyPath As String, bWatchSubTree As Boolean, dwFilters As NOTIFY_EVENTS)
Dim lKeyHandle As Long, lRet As Long
hEvent = CreateEvent(0, True, False, vbNullString)
lRet = RegOpenKey(hKey, sRegKeyPath, lKeyHandle)
RegNotifyChangeKeyValue lKeyHandle, bWatchSubTree, dwFilters, hEvent, True
Do
DoEvents
lRet = WaitForSingleObject(hEvent, 0)
If bExit Then Exit Do
If lRet = WAIT_OBJECT_0 Then
MsgBox "Change!"
ResetEvent hEvent
RegNotifyChangeKeyValue lKeyHandle, bWatchSubTree, dwFilters, hEvent, True
End If
Loop
lRet = RegCloseKey(lKeyHandle)
End
End Sub
----------------------------------------
Ответить
|