Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Mentor
The_Caddie
Posts: 208
Registered: ‎06-08-2010
Message 1 of 3 (217 Views)

If else when checking for registry key

217 Views, 2 Replies
10-12-2012 01:06 AM

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?

*Expert Elite*
pbejse
Posts: 2,441
Registered: ‎11-24-2009
Message 2 of 3 (214 Views)

Re: If else when checking for registry key

10-12-2012 01:19 AM in reply to: The_Caddie

vl-registry-read 

vl-registry-write

vl-registry-delete

 

or

GETENV and SETENV me thinks

 

HTH

 

Contributor
bobdobbs
Posts: 15
Registered: ‎09-27-2012
Message 3 of 3 (192 Views)

Re: If else when checking for registry key

10-12-2012 01:43 PM 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

 

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community