Jump to content
Sign in to follow this  
Luigi

_WinAPI_RegNotifyChangeKeyValue on HKEY_LOCAL_MACHINE64

Recommended Posts

Luigi
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

Share this post


Link to post
Share on other sites
Luigi

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
  • Like 1

Visit my repository

Share this post


Link to post
Share on other sites
satanico64

Thanks @Luigi for your feedback,  i could'nt make it work with hklm.

It's ok with your code now.

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.