Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

If else when checking for registry key

2 REPLIES 2
Reply
Message 1 of 3
The_Caddie
829 Views, 2 Replies

If else when checking for registry key

I want to create a registry key using lisp but only if it dost already exist I know how to use the IF else function and how to create a registry key using lisp but not sure on how to check for the existence of a registry key with in a lisp program?

2 REPLIES 2
Message 2 of 3
pbejse
in reply to: The_Caddie

vl-registry-read 

vl-registry-write

vl-registry-delete

 

or

GETENV and SETENV me thinks

 

HTH

 

Message 3 of 3
bobdobbs
in reply to: The_Caddie

I think vl-registry-write will only make the key if it doesn't exist. Or, rather I should say, you will not lose any values already in that key by using vl-registry-write to try to create it.

 

So, why check first? (Unless you mean a registry "VALUE" or "DATA" and not "KEY")

 

Example:

 

Command: (vl-registry-read "HKEY_CURRENT_USER\\TestA")
nil

Key does not exist


Command: (vl-registry-write "HKEY_CURRENT_USER\\TestA")
T

Now it does but has no values

Command: (vl-registry-read "HKEY_CURRENT_USER\\TestA")
nil

read fails because it looks for a value

Command: (vl-registry-write "HKEY_CURRENT_USER\\TestA" "" "default-value")
"default-value"
I add a value


Command: (vl-registry-read "HKEY_CURRENT_USER\\TestA")
"default-value"

It reads a value


Command: (vl-registry-write "HKEY_CURRENT_USER\\TestA")
T

I re-write the key

Command: (vl-registry-read "HKEY_CURRENT_USER\\TestA")
"default-value"

value is still there

 

 

fugetaboutit

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost