Page 1 of 1

dc_regquery()

Posted: Tue Oct 16, 2012 7:43 am
by c-tec
Hello,
I would like to check if Ghostscript is installed on a computer. So I check the key Computer\HKEY_LOCAL_MACHINE\SOFTWARE\GPL Ghostscript in the registry. But how can I check if the key is present ? Using dc_regquery("Computer\HKEY_LOCAL_MACHINE\SOFTWARE\GPL Ghostscript","") does not work, also dc_regquery(,"Computer\HKEY_CURRENT_USER\Software\GPL Ghostscript","image") . I always get back 2, the same value like keys that are not existing.
regards
Rudolf

Re: dc_regquery()

Posted: Tue Oct 16, 2012 8:58 pm
by rdonnay
I don't have Ghostscript installed on this computer.
What does the actual key look like in the registry?

Re: dc_regquery()

Posted: Wed Oct 17, 2012 12:05 am
by c-tec
Hello Roger,
attached a screenshot, also "Image" instead of "image" does not help.
regards
Rudolf

Re: dc_regquery()

Posted: Wed Oct 17, 2012 2:53 am
by skiman
Hi Rudolf,

Code: Select all

"Computer\HKEY_LOCAL_MACHINE\SOFTWARE\GPL Ghostscript
In your screenshot there is local_USER instead of local_MACHINE? Maybe this the cause?

Re: dc_regquery()

Posted: Wed Oct 17, 2012 4:46 am
by Tom
Hi, Rudolf.

Your syntax:

Code: Select all

dc_regquery("Computer\HKEY_LOCAL_MACHINE\SOFTWARE\GPL Ghostscript","")
is wrong. It should be:

Code: Select all

DC_RegQuery(HKEY_LOCAL_MACHINE,"SOFTWARE\GPL Ghostscript",<cKey>)
Ghostscript creates a key section "GPL Ghostscript" and subsections (folders) with the version number, like "9.04". To be honest, I can't access any keys in HKEY_LOCAL_MACHINE using DC_RegQuery, while HKEY_CURRENT_USER seems to work perfect. I checked for rights, but even an app running with admin rights always returns "2" when doing this.

This works (returns 0, if a key folder exists, and 2 if not):

Code: Select all

DC_RegQuery(HKEY_CURRENT_USER,"SOFTWARE\Microsoft") -> 0
DC_RegQuery(HKEY_CURRENT_USER,"SOFTWARE\Verymicrosoft") -> 2
DC_RegQuery(HKEY_CURRENT_USER,"SOFTWARE\HyCARE") -> 0

Re: dc_regquery()

Posted: Wed Oct 17, 2012 6:45 am
by c-tec
Hello Tom,
thank you, whe I use now dc_regquery( HKEY_CURRENT_USER ,"Software\GPL Ghostscript","") it works now to get 0 if Ghostscript is installed and 2 if not.
regards
Rudolf

Re: dc_regquery()

Posted: Wed Oct 17, 2012 6:53 am
by Tom
Hi, Rudolf.

Excellent. :)

But it won't work if Ghostscript was installed for all users by the admin. Then, the Ghostscript section resides in HKEY_LOCAL_MACHINE. DC_RegQuery does not return "0" in that situation.