Luigi Posted July 8, 2014 Share Posted July 8, 2014 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 More sharing options...
Solution JFX Posted July 8, 2014 Solution Share Posted July 8, 2014 I belive $HKEY_LOCAL_MACHINE is not same value the HKEY_LOCAL_MACHINE64, is correctly? There is no such thing as HKEY_LOCAL_MACHINE64. You have to put the right flags to RegOpenKey like KEY_WOW64_64KEY See http://msdn.microsoft.com/en-us/library/windows/desktop/ms724878(v=vs.85).aspx Luigi 1 Link to comment Share on other sites More sharing options...
Luigi Posted July 9, 2014 Author Share Posted July 9, 2014 Problem solved! Thank you JFX! Cool! expandcollapse popup#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 satanico64 1 Visit my repository Link to comment Share on other sites More sharing options...
satanico64 Posted December 13, 2017 Share Posted December 13, 2017 Thanks @Luigi for your feedback, i could'nt make it work with hklm. It's ok with your code now. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now