#Include <Constants.au3>
#Include <WinAPIEx.au3>
Global $Array1,$Array2,$Array3,$Array4
$sReg = _RegExportEx('HKEY_CLASSES_ROOT')
FileWrite("HKCR.txt", $sReg)
_KeyList1("HKEY_CURRENT_USER")
FileWrite("HKCU.txt", "HKEY_CURRENT_USER" & @CRLF)
FileWrite("HKCU.txt", $Array1)
_KeyList2("HKEY_LOCAL_MACHINE")
FileWrite("HKLM.txt", "HKEY_LOCAL_MACHINE" & @CRLF)
FileWrite("HKLM.txt", $Array2)
_KeyList3("HKEY_USERS")
FileWrite("HKU.txt", "HKEY_USERS" & @CRLF)
FileWrite("HKU.txt", $Array3)
_KeyList4("HKEY_CURRENT_CONFIG")
FileWrite("HKCC.txt", "HKEY_CURRENT_CONFIG" & @CRLF)
FileWrite("HKCC.txt", $Array4)
Func _RegExportEx($sKey, $fAssurance = 0)
Local $tData, $hRoot,$sReg = '', $Error = 1, $sRoot = $sKey
$sKey = StringTrimLeft($sKey, StringLen($sRoot) + 1)
Do
$hRoot = _WinAPI_RegOpenKey(Eval($sRoot), $sKey, BitOR($KEY_ENUMERATE_SUB_KEYS, $KEY_QUERY_VALUE))
If @error Then
ExitLoop
EndIf
$tData = DllStructCreate('byte[1048576]')
If Not _RegEnumProc($hRoot, StringRegExpReplace($sRoot & '\' & $sKey, '\\*\Z', ''), $fAssurance, $sReg, $tData) Then
ExitLoop
EndIf
$Error = 0
Until 1
If $Error Then
Switch @extended
Case 0
$Error = -1
Case Else
$Error = @extended
EndSwitch
EndIf
If $hRoot Then
_WinAPI_RegCloseKey($hRoot)
EndIf
If $Error Then
Return SetError(2, $Error, '')
EndIf
Return $sReg
EndFunc
Func _RegEnumProc($hRoot, $sRoot, $fAssurance, ByRef $sData, ByRef $tData, $sParam = 0)
Local $hKey, $sKey, $sVal, $Pos, $Size, $Type
Local $pData = DllStructGetPtr($tData)
Local $Count = 0, $Error = 0
If $sParam Then
$sData &= $sRoot & '\' & $sParam & @CRLF
Else
$sData = $sRoot & @CRLF
EndIf
While 1
$sKey = _WinAPI_RegEnumKey($hRoot, $Count)
If @error Then
Switch @extended
Case 259
ExitLoop
Case Else
Return SetError(1, @extended, 0)
EndSwitch
EndIf
$hKey = _WinAPI_RegOpenKey($hRoot, $sKey, BitOR($KEY_ENUMERATE_SUB_KEYS, $KEY_QUERY_VALUE))
If @error Then
If $fAssurance Then
Return SetError(1, @extended, 0)
EndIf
Else
If $sParam Then
_RegEnumProc($hKey, $sRoot, $fAssurance, $sData, $tData, $sParam & '\' & $sKey)
Else
_RegEnumProc($hKey, $sRoot, $fAssurance, $sData, $tData, $sKey)
EndIf
If @error Then
Switch @extended
Case 0
$Error = -1
Case Else
$Error = @extended
EndSwitch
EndIf
EndIf
If $hKey Then
_WinAPI_RegCloseKey($hKey)
EndIf
$Count += 1
If $Error Then
ExitLoop
EndIf
WEnd
If $Error Then
Return SetError(1, $Error, 0)
Else
Return 1
EndIf
EndFunc
Func _KeyList1($key)
$i = 1
While 1
$var = RegEnumKey($key, $i)
If @error <> 0 then ExitLoop
$Array1 &= $key&"\"&$var & @CRLF
$i = $i + 1
_KeyList1($key&"\"&$var)
WEnd
EndFunc
Func _KeyList2($key)
$i = 1
While 1
$var = RegEnumKey($key, $i)
If @error <> 0 then ExitLoop
$Array2 &= $key&"\"&$var & @CRLF
$i = $i + 1
_KeyList2($key&"\"&$var)
WEnd
EndFunc
Func _KeyList3($key)
$i = 1
While 1
$var = RegEnumKey($key, $i)
If @error <> 0 then ExitLoop
$Array3 &= $key&"\"&$var & @CRLF
$i = $i + 1
_KeyList3($key&"\"&$var)
WEnd
EndFunc
Func _KeyList4($key)
$i = 1
While 1
$var = RegEnumKey($key, $i)
If @error <> 0 then ExitLoop
$Array4 &= $key&"\"&$var & @CRLF
$i = $i + 1
_KeyList4($key&"\"&$var)
WEnd
EndFunc
assch сказал(а):Ваша функция отлично снимает ключи на ветки HKCR -13 секунд против 57 секунд.
А вот на остальных ветках отстаёт например ветку HKLM -17 секунд против 4 секунд.
#Include <WinAPIEx.au3>
$hKey = _WinAPI_RegOpenKey($HKEY_CLASSES_ROOT, ".djvu")
DllCall ( "Advapi32.dll", "int", "RegNotifyChangeKeyValue", "hwnd", $hKey, "int", TRUE, "int", 0x00000001, "int", FALSE, "int", TRUE)
#Include <WinAPIEx.au3>
$a = "HKEY_LOCAL_MACHINE"
Global $sData
_KeyList($a)
$Txt = FileOpen("1.txt",2)
FileWrite($Txt, $sData)
FileClose($Txt)
Func _KeyList($key)
$i = 1
While 1
$var = RegEnumKey($key, $i)
If @error <> 0 then ExitLoop
$Array = $key&"\"& $var
$w1 = StringInStr($Array,"\",0,1)
$w2 = StringTrimLeft($Array, $w1)
$hKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, $w2)
$tTime = _WinAPI_RegQueryLastWriteTime($hKey)
_WinAPI_RegCloseKey($hKey)
$sData &= $a & '\' & $w2 & '\' & DllStructGetData($tTime, 1) & @CRLF
$i = $i + 1
_KeyList($key&"\"&$var)
WEnd
EndFunc
assch сказал(а):Есть функция RegNotifyChangeKeyValue()...
Global Const $REG_NOTIFY_CHANGE_NAME = 0x01
Global Const $REG_NOTIFY_CHANGE_ATTRIBUTES = 0x02
Global Const $REG_NOTIFY_CHANGE_LAST_SET = 0x04
Global Const $REG_NOTIFY_CHANGE_SECURITY = 0x08
; #FUNCTION# ====================================================================================================================
; Name...........: _WinAPI_RegNotifyChangeKeyValue
; Description....: Notifies the caller about changes to the attributes or contents of a specified registry key.
; Syntax.........: _WinAPI_RegNotifyChangeKeyValue ( $hKey, $iFilter [, $fSubtree [, $fAsync [, $hEvent]]] )
; Parameters.....: $hKey - Handle to an open registry key. The key must have been opened with the KEY_NOTIFY access right.
; This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function. It can also
; be one of the following predefined keys.
;
; $HKEY_CLASSES_ROOT
; $HKEY_CURRENT_CONFIG
; $HKEY_CURRENT_USER
; $HKEY_LOCAL_MACHINE
; $HKEY_USERS
;
; $iFilter - Indicates the changes that should be reported. This parameter can be one or more of the following values.
;
; $REG_NOTIFY_CHANGE_NAME
; $REG_NOTIFY_CHANGE_ATTRIBUTES
; $REG_NOTIFY_CHANGE_LAST_SET
; $REG_NOTIFY_CHANGE_SECURITY
;
; $fSubtree - Specifies whether report changes in the subkeys of the specified key, valid values:
; |TRUE - The function reports changes in the specified key and all its subkeys.
; |FALSE - The function reports changes only in the specified key. (Default)
; $fAsync - Specifies whether return immediately, valid values:
; |TRUE - The function returns immediately and reports changes by signaling the specified event.
; |FALSE - The function does not return until a change has occurred. (Default)
; $hEvent - Handle to an event. If the $fAsync parameter is TRUE, the function returns immediately and changes are
; reported by signaling this event, otherwise this parameter is ignored.
; Return values..: Success - 1.
; Failure - 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.
; Author.........: Yashied
; Modified.......:
; Remarks........: If the specified key is closed, the event is signaled. This means that an application should not depend on the
; key being open after returning from a wait operation on the event.
; Related........:
; Link...........: @@MsdnLink@@ RegNotifyChangeKeyValue
; Example........: Yes
; ===============================================================================================================================
Func _WinAPI_RegNotifyChangeKeyValue_($hKey, $iFilter, $fSubtree = 0, $fAsync = 0, $hEvent = 0)
Local $Ret = DllCall('advapi32.dll', 'long', 'RegNotifyChangeKeyValue', 'ulong_ptr', $hKey, 'int', $fSubtree, 'dword', $iFilter, 'ptr', $hEvent, 'int', $fAsync)
If @error Then
Return SetError(1, 0, 0)
Else
If $Ret[0] Then
Return SetError(1, $Ret[0], 0)
EndIf
EndIf
Return 1
EndFunc ;==>_WinAPI_RegNotifyChangeKeyValue
#Include <WinAPIEx.au3>
$hKey = _WinAPI_RegOpenKey($HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Run', $KEY_NOTIFY)
If _WinAPI_RegNotifyChangeKeyValue_($hKey, $REG_NOTIFY_CHANGE_LAST_SET) Then
MsgBox(48, 'Registry', 'The registry hive has been modified.' & @CR & @CR & 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run')
EndIf
_WinAPI_RegCloseKey($hKey)
#NoTrayIcon
#Include <WinAPIEx.au3>
#Include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Opt('TrayMenuMode', 3)
Opt('WinTitleMatchMode', 3)
Opt('WinWaitDelay', 0)
Global Const $REG_NOTIFY_CHANGE_NAME = 0x01
Global Const $REG_NOTIFY_CHANGE_ATTRIBUTES = 0x02
Global Const $REG_NOTIFY_CHANGE_LAST_SET = 0x04
Global Const $REG_NOTIFY_CHANGE_SECURITY = 0x08
Global $hKey, $tData
If ($CmdLine[0]) And ($CmdLine[1] = '-notify') Then
$hKey = _WinAPI_RegOpenKey($HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Run', $KEY_NOTIFY)
If _WinAPI_RegNotifyChangeKeyValue_($hKey, $REG_NOTIFY_CHANGE_LAST_SET) Then
$tData = DllStructCreate('ulong_ptr;dword;ptr')
For $i = 1 To 3
DllStructSetData($tData, $i, 0)
Next
DllCall('user32.dll', 'lresult', 'SendMessage', 'hwnd', WinGetHandle('#RegHelper'), 'uint', $WM_COPYDATA, 'ptr', 0, 'ptr', DllStructGetPtr($tData))
EndIf
_WinAPI_RegCloseKey($hKey)
Exit
EndIf
Global $hForm, $Msg, $ItemExit, $PID, $Notify = False
$hForm = GUICreate('#RegHelper')
GUIRegisterMsg($WM_COPYDATA, 'WM_COPYDATA')
$ItemExit = TrayCreateItem('Exit')
TraySetClick(8)
TraySetState()
$PID = Run(@ScriptFullPath & ' -notify')
While 1
If $Notify Then
$Notify = 0
$PID = Run(@ScriptFullPath & ' -notify')
Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(48, ''Registry'', ''The registry hive has been modified.'', 5)"')
EndIf
$Msg = TrayGetMsg()
Switch $Msg
Case $ItemExit
ProcessClose($PID)
Exit
EndSwitch
WEnd
Func _WinAPI_RegNotifyChangeKeyValue_($hKey, $iFilter, $fSubtree = 0, $fAsync = 0, $hEvent = 0)
Local $Ret = DllCall('advapi32.dll', 'long', 'RegNotifyChangeKeyValue', 'ulong_ptr', $hKey, 'int', $fSubtree, 'dword', $iFilter, 'ptr', $hEvent, 'int', $fAsync)
If @error Then
Return SetError(1, 0, 0)
Else
If $Ret[0] Then
Return SetError(1, $Ret[0], 0)
EndIf
EndIf
Return 1
EndFunc ;==>_WinAPI_RegNotifyChangeKeyValue
Func WM_COPYDATA($hWnd, $iMsg, $wParam, $lParam)
Switch $hWnd
Case 0
Case $hForm
$Notify = 1
Return 1
EndSwitch
Return 0
EndFunc ;==>WM_COPYDATA
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global $hKey, $hEvent
$hEvent = _WinAPI_CreateEvent()
$hKey = _WinAPI_RegOpenKey($HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Run', $KEY_NOTIFY)
If Not _WinAPI_RegNotifyChangeKeyValue($hKey, $REG_NOTIFY_CHANGE_LAST_SET, 0, 1, $hEvent) Then
Exit
EndIf
While 1
If Not _WinAPI_WaitForSingleObject($hEvent, 0) Then
MsgBox(48, 'Registry', 'The registry hive has been modified.' & @CR & @CR & 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run')
ExitLoop
EndIf
Sleep(100)
WEnd
_WinAPI_CloseHandle($hEvent)
_WinAPI_RegCloseKey($hKey)
assch сказал(а):Только когда закрываешь сигнальное окно, почему то зыкрывается сам скрипт.
#Include <NotifyBox.au3>
#Include <WinAPIEx.au3>
Opt('TrayAutoPause', 0)
Global Const $REG_NOTIFY_CHANGE_NAME = 0x01
Global Const $REG_NOTIFY_CHANGE_ATTRIBUTES = 0x02
Global Const $REG_NOTIFY_CHANGE_LAST_SET = 0x04
Global Const $REG_NOTIFY_CHANGE_SECURITY = 0x08
$hEvent = _WinAPI_CreateEvent()
$hKey = _WinAPI_RegOpenKey($HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Run', $KEY_NOTIFY)
If Not _WinAPI_RegNotifyChangeKeyValue($hKey, $REG_NOTIFY_CHANGE_LAST_SET, 0, 1, $hEvent) Then
Exit
EndIf
While 1
If Not _WinAPI_WaitForSingleObject($hEvent, 0) Then
_NotifyBox(48, 'Registry', 'The registry hive has been modified.' & @CR & @CR & 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run', 5)
If Not _WinAPI_RegNotifyChangeKeyValue($hKey, $REG_NOTIFY_CHANGE_LAST_SET, 0, 1, $hEvent) Then
ExitLoop
EndIf
EndIf
Sleep(100)
WEnd
_WinAPI_CloseHandle($hEvent)
_WinAPI_RegCloseKey($hKey)
Func _WinAPI_RegNotifyChangeKeyValue($hKey, $iFilter, $fSubtree = 0, $fAsync = 0, $hEvent = 0)
Local $Ret = DllCall('advapi32.dll', 'long', 'RegNotifyChangeKeyValue', 'ulong_ptr', $hKey, 'int', $fSubtree, 'dword', $iFilter, 'ptr', $hEvent, 'int', $fAsync)
If @error Then
Return SetError(1, 0, 0)
Else
If $Ret[0] Then
Return SetError(1, $Ret[0], 0)
EndIf
EndIf
Return 1
EndFunc ;==>_WinAPI_RegNotifyChangeKeyValue
assch сказал(а):Функция лежит в библиотеке WinAPIEx.au3?
Yashied сказал(а):assch сказал(а):Только когда закрываешь сигнальное окно, почему то зыкрывается сам скрипт.
Ну это просто пример. Вот:
Код:#Include <NotifyBox.au3> #Include <WinAPIEx.au3> Opt('TrayAutoPause', 0) Global Const $REG_NOTIFY_CHANGE_NAME = 0x01 Global Const $REG_NOTIFY_CHANGE_ATTRIBUTES = 0x02 Global Const $REG_NOTIFY_CHANGE_LAST_SET = 0x04 Global Const $REG_NOTIFY_CHANGE_SECURITY = 0x08 $hEvent = _WinAPI_CreateEvent() $hKey = _WinAPI_RegOpenKey($HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Run', $KEY_NOTIFY) If Not _WinAPI_RegNotifyChangeKeyValue($hKey, $REG_NOTIFY_CHANGE_LAST_SET, 0, 1, $hEvent) Then Exit EndIf While 1 If Not _WinAPI_WaitForSingleObject($hEvent, 0) Then _NotifyBox(48, 'Registry', 'The registry hive has been modified.' & @CR & @CR & 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run', 5) If Not _WinAPI_RegNotifyChangeKeyValue($hKey, $REG_NOTIFY_CHANGE_LAST_SET, 0, 1, $hEvent) Then ExitLoop EndIf EndIf Sleep(100) WEnd _WinAPI_CloseHandle($hEvent) _WinAPI_RegCloseKey($hKey) Func _WinAPI_RegNotifyChangeKeyValue($hKey, $iFilter, $fSubtree = 0, $fAsync = 0, $hEvent = 0) Local $Ret = DllCall('advapi32.dll', 'long', 'RegNotifyChangeKeyValue', 'ulong_ptr', $hKey, 'int', $fSubtree, 'dword', $iFilter, 'ptr', $hEvent, 'int', $fAsync) If @error Then Return SetError(1, 0, 0) Else If $Ret[0] Then Return SetError(1, $Ret[0], 0) EndIf EndIf Return 1 EndFunc ;==>_WinAPI_RegNotifyChangeKeyValue
NotifyBox.au3
D:\test1.au3(8,44) : ERROR: $REG_NOTIFY_CHANGE_NAME previously declared as a 'Const'
Global Const $REG_NOTIFY_CHANGE_NAME = 0x01
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\test1.au3(9,50) : ERROR: $REG_NOTIFY_CHANGE_ATTRIBUTES previously declared as a 'Const'
Global Const $REG_NOTIFY_CHANGE_ATTRIBUTES = 0x02
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\test1.au3(10,48) : ERROR: $REG_NOTIFY_CHANGE_LAST_SET previously declared as a 'Const'
Global Const $REG_NOTIFY_CHANGE_LAST_SET = 0x04
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\test1.au3(11,48) : ERROR: $REG_NOTIFY_CHANGE_SECURITY previously declared as a 'Const'
Global Const $REG_NOTIFY_CHANGE_SECURITY = 0x08
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\test1.au3(32,95) : ERROR: _WinAPI_RegNotifyChangeKeyValue() already defined.
Func _WinAPI_RegNotifyChangeKeyValue($hKey, $iFilter, $fSubtree = 0, $fAsync = 0, $hEvent = 0)