Jump to content

_WinAPI_RegNotifyChangeKeyValue on HKEY_LOCAL_MACHINE64


Go to solution Solved by JFX,

Recommended Posts

Hi Forum,
 
Is possible the _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, 'SOFTWAREMicrosoftWindowsCurrentVersionUninstall', $KEY_NOTIFY) open something like $HKEY_LOCAL_MACHINE_64? On Windows 7 x64?
I try search a binary value for HKEY_LOCAL_MACHINE64, to use in _WinAPI_RegOpenKey, this exist? This work?
Or not work this way?
I belive $HKEY_LOCAL_MACHINE is not same value the HKEY_LOCAL_MACHINE64, is correctly?
 
Thank you for answer.
 
#include <APIRegConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIReg.au3>
 
Opt('TrayAutoPause', 0)
 
Local $hKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', $KEY_NOTIFY)
If @error Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
    Exit
EndIf
Local $hEvent = _WinAPI_CreateEvent()
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
        Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(4096, ''Registry'', ''The registry hive has been modified.'' & @CRLF & @CRLF & ''HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'', 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)

 

Visit my repository

Link to comment
Share on other sites

Problem solved! Thank you JFX!
Cool!

#include <APIRegConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIReg.au3>
HotKeySet('^+{END}', '_quit') ; Ctrl+Shift+END
Opt('TrayAutoPause', 0)
 
Local $hKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', BitOR($KEY_NOTIFY, $KEY_WOW64_64KEY))
If @error Then
ConsoleWrite('linha[' & @ScriptLineNumber & '] @error[' & @error & '] @extended[' & @extended & '] msg[' & _WinAPI_GetErrorMessage(@extended) & ']' & @LF)
Exit
EndIf
_WinAPI_RegQueryReflectionKey($hKey)
ConsoleWrite('linha[' & @ScriptLineNumber & '] @error[' & @error & '] @extended[' & @extended & '] msg[' & _WinAPI_GetErrorMessage(@extended) & ']' & @LF)
 
Local $hEvent = _WinAPI_CreateEvent()
If Not _WinAPI_RegNotifyChangeKeyValue($hKey, $REG_NOTIFY_CHANGE_LAST_SET, 0, 1, $hEvent) Then
ConsoleWrite('linha[' & @ScriptLineNumber & '] @error[' & @error & '] @extended[' & @extended & '] msg[' & _WinAPI_GetErrorMessage(@extended) & ']' & @LF)
Exit
EndIf
AdlibRegister('_quit', 3500)
While 1
If Not _WinAPI_WaitForSingleObject($hEvent, 0) Then
ConsoleWrite('Change value!' & @LF)
Beep(700, 100)
Beep(700, 100)
Beep(700, 200)
If Not _WinAPI_RegNotifyChangeKeyValue($hKey, $REG_NOTIFY_CHANGE_LAST_SET, 0, 1, $hEvent) Then
ExitLoop
EndIf
EndIf
Sleep(500)
test()
WEnd
 
Func test()
Local Static $iTry = 0
If Not $iTry Then
;~  Local $hWrite = RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run', 'TEST_KEY', 'REG_SZ', 'Hello this is a test')
Local $hWrite = RegWrite('HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', 'TEST_KEY', 'REG_SZ', 'Hello this is a test')
ConsoleWrite('$hWrite[ ' & $hWrite & ' ]' & @LF)
Sleep(2000)
;~  Local $hRemove = RegDelete ('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run', 'TEST_KEY')
Local $hRemove = RegDelete('HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', 'TEST_KEY')
ConsoleWrite('$hRemove[ ' & $hRemove & ' ]' & @LF)
$iTry = 1
EndIf
EndFunc   ;==>test
 
Func _quit()
AdlibUnRegister('_quit')
Beep(700, 200)
_WinAPI_CloseHandle($hEvent)
_WinAPI_RegCloseKey($hKey)
Exit
EndFunc   ;==>_quit

Visit my repository

Link to comment
Share on other sites

  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...