Jump to content

Registry Key exist or not


Recommended Posts

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

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

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 by taylansan
commented console write

TY.

Link to comment
Share on other sites

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 by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

I made this function some time ago :

Func _RegExists($sKeyname, $sValueName = "")
    RegRead($sKeyName, $sValueName)
    Return ( $svalueName = "" ? @error <= 0 : @error = 0 )
EndFunc

 

Link to comment
Share on other sites

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 by DigDeep
Link to comment
Share on other sites

  • 5 years later...
  • Developers

@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

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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