DigDeep Posted March 24, 2017 Share Posted March 24, 2017 Hi, I am sure this might have been done earlier but dono where am I going wrong. HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Direct3D\Drivers I just need to know if the subkey Drivers exists in Direct3D key or not. I don't want any key value or data. I did tried with RegEnumKey too but I am not getting it correctly. Local $Drv = HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Direct3D\Drivers If $Drv exists then ; do something Else MsgBox(0, '', 'Drivers Key does not Exist') EndIf Link to comment Share on other sites More sharing options...
iamtheky Posted March 24, 2017 Share Posted March 24, 2017 Its first underneath Direct3D on my few boxes, so this works msgbox(0, '' , execute('RegEnumKey("HKLM\SOFTWARE\WOW6432Node\Microsoft\Direct3D" , 1) = "Drivers" ? "Yes" : "No"')) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Subz Posted March 24, 2017 Share Posted March 24, 2017 I normally use the following function _RegKeyExists in the RegFunc UDF. Link to comment Share on other sites More sharing options...
DigDeep Posted March 24, 2017 Author Share Posted March 24, 2017 (edited) @iamtheky , what if I don't if it would be first or 4th underneath? It shows 3rd line on my Registry. @Subz thanks you too. Looking into yours too once. Edited March 24, 2017 by DigDeep Link to comment Share on other sites More sharing options...
taylansan Posted March 24, 2017 Share Posted March 24, 2017 (edited) Similar to the key's; you can check one by one each element: Local $sSubKey = "", $i = 1, $bExists = False While 1 ;check the folders one by one $sSubKey = RegEnumKey("HKLM\SOFTWARE\WOW6432Node\Microsoft\Direct3D", $i) ;or HKLM64 ;ConsoleWrite($sSubKey & @CRLF) If @error Then ExitLoop If $sSubKey = "Drivers" Then $bExists = True ExitLoop EndIf $i = $i + 1 WEnd ConsoleWrite($bExists & @CRLF) Edited March 24, 2017 by taylansan commented console write TY. Link to comment Share on other sites More sharing options...
iamtheky Posted March 24, 2017 Share Posted March 24, 2017 (edited) maybe misuse @error, because: Since type cant be messed up in this use case, if the key could be opened the @error value will be 0 or less (either success or value could not be accessed). #RequireAdmin $a = RegRead("HKLM\SOFTWARE\WOW6432Node\Microsoft\Direct3D\Drivers" , "test") msgbox(0, '' , @error <= 0 ? "YES" : "NO") Edited March 24, 2017 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
jguinch Posted March 24, 2017 Share Posted March 24, 2017 I made this function some time ago : Func _RegExists($sKeyname, $sValueName = "") RegRead($sKeyName, $sValueName) Return ( $svalueName = "" ? @error <= 0 : @error = 0 ) EndFunc Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
DigDeep Posted March 24, 2017 Author Share Posted March 24, 2017 (edited) It looks wierd here... @Subz I tried using your Func _RegKeyExist I even tried using the _RegSubkeySearch It searches few keys, even sub keys correctly but does not read some. Just to add here, I when I tried adding the @error with _RegKeyExist, it gave me 2 - Target key does not exist and with RegSubkeySearch, Failure - 0. But all the below keys were existing... $key = _RegKeyExists("HKLM\SOFTWARE\WOW6432Node\Microsoft\Direct3D") MsgBox(0, '', $key) = 1 OR $key = _RegKeyExists("HKLM\SOFTWARE\WOW6432Node\Microsoft\Direct3D\Drivers") MsgBox(0, '', $key) = 1 OR $key = _RegKeyExists("HKLM\SOFTWARE\WOW6432Node\Microsoft\Direct3D\Drivers\Direct3D") MsgBox(0, '', $key) = 1 OR $key = _RegKeyExists("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") MsgBox(0, '', $key) = 1 BUT... $key = _RegKeyExists("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications") MsgBox(0, '', $key) = 0 And $key = _RegKeyExists("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate") MsgBox(0, '', $key) = 0 @taylansan I even tried with your example but get the same result as above. I tried compilation on multiple machines also but all the machines gave me the same above results. Edited March 24, 2017 by DigDeep Link to comment Share on other sites More sharing options...
Subz Posted March 25, 2017 Share Posted March 25, 2017 The problem is "HKEY_LOCAL_MACHINE" == "HKLM" i.e. 32bit key, you need to use "HKLM64" to get 64bit keys. DigDeep 1 Link to comment Share on other sites More sharing options...
taylansan Posted March 25, 2017 Share Posted March 25, 2017 Did you try for this? I mentioned about HKLM64 in the comment. $sSubKey = RegEnumKey("HKLM\SOFTWARE\WOW6432Node\Microsoft\Direct3D", $i) ;or HKLM64 TY. Link to comment Share on other sites More sharing options...
DigDeep Posted March 27, 2017 Author Share Posted March 27, 2017 Thanks @Subz and all. I tried with the below and it's working now. _RegKeyExists("HKLM64\... Link to comment Share on other sites More sharing options...
mannworks00 Posted March 3, 2023 Share Posted March 3, 2023 (edited) RegRead is returning a blank or "" when it's unable to find a key. So, this worked for me in 2023 with Autoit v. 3.3.16.1. Func RegExists($path, $key) return (RegRead($path, $key) == "" ? False : True) EndFunc Edited March 3, 2023 by mannworks00 Link to comment Share on other sites More sharing options...
Developers Jos Posted March 4, 2023 Developers Share Posted March 4, 2023 @mannworks00, Why are you resurrecting again an old topic like you did here: Last warning: Simply do not reply to OLD THREADS as people aren't waiting for that answer anymore! SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts