Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Inno Setup - Read Registry Entry?

4,394 views
Skip to first unread message

Ken Mayer [dBVIPS]

unread,
Sep 27, 2008, 12:53:44 PM9/27/08
to
Is it possible (I'm sure it must be) to get Inno to read the registry
for a specific entry? The reason I'm asking is that I have a freeware
app that needs the users to download and place updated data (Unix-Text
format) in the folder for the app. What I was considering was using Inno
to see where the application is installed, and having it put the two
files needed in the same folder. I know how to set up the registry entry
from the application (a dBASE app) just fine ... what I was wondering
was about Inno itself? I would want to get the registry entry with the
path, and then use that for the install location for the data files.

Ideas? (I'm being lazy, because I've been sick -- I could probably hunt
this down, but if someone's already done something like it, it seems
silly to re-invent ...)

Thanks in advance --

Ken

--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase

Andrew Shimmin

unread,
Sep 27, 2008, 6:37:35 PM9/27/08
to
Try adapting the following:

function GetRuntimeFolder(Default: String): String;
{function to get the runtime install folder}
var ResultStr: String;
begin
Result:='{app}';
if RegQueryStringValue(HKLM,'SOFTWARE\dBASE\PLUS\series1','RuntimePath',ResultStr) then
Result:=ResultStr
end;

regards, andrew

Andrew Shimmin

unread,
Sep 27, 2008, 8:48:05 PM9/27/08
to
This will depend on the freeware app writing a registry entry on install. If not, then another strategy is needed.

As a crude solution why not just place the files in the freeware install folder by hard coding the freeware install path into your code? I am assuming the app install does not give the user a choice of where it is installed.

Of course on Vista, with the UAC enabled, this is going to be a problem. If the install is in CSIDL_PROGRAM_FILES your code will need to run with a full admin access token.

regards, andrew

Ken Mayer [dBVIPS] wrote:
> Thanks, I will see what I can see. It may be a little bit -- this is a
> low priority item, but that should put me on the right path (I hope!).
>
> Ken

Ken Mayer [dBVIPS]

unread,
Sep 27, 2008, 7:35:08 PM9/27/08
to
Thanks, I will see what I can see. It may be a little bit -- this is a
low priority item, but that should put me on the right path (I hope!).

Ken

Andrew Shimmin wrote:
> Try adapting the following:
>
> function GetRuntimeFolder(Default: String): String;
> {function to get the runtime install folder}
> var ResultStr: String;
> begin
> Result:='{app}';
> if
> RegQueryStringValue(HKLM,'SOFTWARE\dBASE\PLUS\series1','RuntimePath',ResultStr)
> then
> Result:=ResultStr
> end;
>
> regards, andrew

Ken Mayer [dBVIPS]

unread,
Sep 27, 2008, 8:53:15 PM9/27/08
to
Andrew Shimmin wrote:
> This will depend on the freeware app writing a registry entry on
> install. If not, then another strategy is needed.
>
> As a crude solution why not just place the files in the freeware install
> folder by hard coding the freeware install path into your code? I am
> assuming the app install does not give the user a choice of where it is
> installed.

I'd rather give users a *little* bit of option. <g>

> Of course on Vista, with the UAC enabled, this is going to be a problem.
> If the install is in CSIDL_PROGRAM_FILES your code will need to run with
> a full admin access token.

Yeah. I've been looking at your issues. I haven't delved into them
deeply, but ...

Thanks, again.

Ken

Andrew Shimmin

unread,
Sep 27, 2008, 10:15:23 PM9/27/08
to
> I'd rather give users a *little* bit of option. <g>

I have come to the conclusion giving users an install choice, apart from a network install, is not a good idea. I always install to CSIDL_PROGRAM_FILES\CompanyName\ApplicationName. On Vista it saves a whole bunch of hassles.

regards, andrew

Bernd Hohenester

unread,
Sep 29, 2008, 1:36:28 PM9/29/08
to
Hello,

> Try adapting the following:
>
> function GetRuntimeFolder(Default: String): String;
> {function to get the runtime install folder}
> var ResultStr: String;
> begin
> Result:='{app}';
> if
> RegQueryStringValue(HKLM,'SOFTWARE\dBASE\PLUS\series1','RuntimePath',ResultStr)
> then
> Result:=ResultStr
> end;
>

i guess there is a way to get it really easier:

[Files]
Source: MyFile.Ext; DestDir:
{reg:HKLM\SOFTWARE\dBASE\PLUS\series1,RuntimePath|{app}}


see inno setup compiler help for "{reg:..." constant.

cu
Bernd

Jonny Kwekkeboom

unread,
Oct 7, 2008, 11:32:58 AM10/7/08
to
Hi,

or you can set a ISSP Variable for the folder out of read registry

Like:

#define InnoFolder ReadReg(HKEY_LOCAL_MACHINE,
"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1",
"Inno Setup: App Path")

cu
Jonny

Andrew Shimmin

unread,
Oct 8, 2008, 7:16:43 PM10/8/08
to
> DefaultDirName=OandADir()

I am not sure I understand your problem correctly, however, the function is used in INNO this way:

DefaultDirName={code:OandDir}

You can also use:

#define OandADir ReadReg(HKEY_LOCAL_MACHINE,"Software\Golden Stag Productions\OandA","Path")
DefaultDirName={#OandDir}

or

DefaultDirName={reg:HKEY_LOCAL_MACHINE\Software\Golden Stag Productions\OandA,Path|{app}}

regards, andrew

Ken Mayer [dBVIPS] wrote:


> Andrew Shimmin wrote:
>> Try adapting the following:
>>
>> function GetRuntimeFolder(Default: String): String;
>> {function to get the runtime install folder}
>> var ResultStr: String;
>> begin
>> Result:='{app}';
>> if
>> RegQueryStringValue(HKLM,'SOFTWARE\dBASE\PLUS\series1','RuntimePath',ResultStr)
>> then
>> Result:=ResultStr
>> end;
>>
>

> Using the following code (based on yours above), I am guessing it works
> (no errors during the compile/run), but when I try to use it in the
> script and run the Installer, for the path I am getting:
>
> C:\OandAData\InstallImage\OandADir()
>
> Which is not what I want. The statement that uses this is in the Setup
> section:
>
> DefaultDirName=OandADir()
>
> Should I be doing this elsewhere?
>
> Ken
>
> ; ------------------------------------------------------
> ; Code to get the folder I need from the Registry:
> [Code]
>
> var ResultStr: String;
> function OandADir( Default: String): String;
> begin
> Result := '{app}';
> if RegQueryStringValue( HKLM, 'Software\Golden Stag
> Productions\OandA', 'Path', ResultStr)
> then
> Result := ResultStr;
> end;
>

Ken Mayer [dBVIPS]

unread,
Oct 8, 2008, 10:58:15 AM10/8/08
to
Andrew Shimmin wrote:
> Try adapting the following:
>
> function GetRuntimeFolder(Default: String): String;
> {function to get the runtime install folder}
> var ResultStr: String;
> begin
> Result:='{app}';
> if
> RegQueryStringValue(HKLM,'SOFTWARE\dBASE\PLUS\series1','RuntimePath',ResultStr)
> then
> Result:=ResultStr
> end;
>

Using the following code (based on yours above), I am guessing it works

(no errors during the compile/run), but when I try to use it in the
script and run the Installer, for the path I am getting:

C:\OandAData\InstallImage\OandADir()

Which is not what I want. The statement that uses this is in the Setup
section:

DefaultDirName=OandADir()

Should I be doing this elsewhere?

Ken

; ------------------------------------------------------
; Code to get the folder I need from the Registry:
[Code]

var ResultStr: String;
function OandADir( Default: String): String;
begin
Result := '{app}';


if RegQueryStringValue( HKLM, 'Software\Golden Stag
Productions\OandA', 'Path', ResultStr)
then
Result := ResultStr;
end;

--

Ken Mayer [dBVIPS]

unread,
Oct 9, 2008, 9:13:11 AM10/9/08
to
Turns out I needed to expand the Inno Constant in the code -- it appears
to work properly now with or without registry entries:

; ------------------------------------------------------
; Code to get the folder I need from the Registry:
[Code]

function OandADir( Default: String): String;

var ResultStr: String;
begin


if RegQueryStringValue( HKLM, 'Software\Golden Stag
Productions\OandA', 'Path', ResultStr)
then
Result := ResultStr

else
Result := ExpandConstant( '{pf}\OandA' )

Ken Mayer [dBVIPS]

unread,
Oct 9, 2008, 8:27:47 AM10/9/08
to
Andrew Shimmin wrote:
>> DefaultDirName=OandADir()
>
> I am not sure I understand your problem correctly, however, the function
> is used in INNO this way:
>
> DefaultDirName={code:OandDir}

This works, *if* the entry is in the registry. If, however, the entry is
not there, it doesn't. This may be an issue with the function (below).

Here's what I'm trying to do:

If the entry is in the registry, use that, otherwise use the default for
the DefaultDir of '{pf}\OandA', which should expand out to "C:\Program
Files\OandA". What is showing up in the installer dialog, if the
registry entry does not exist is: C:\OandAData\InstallImage\{pf}\OandA

Sigh. It's always somethin' ... thanks!

Ken

[Code]


function OandADir( Default: String): String;

var ResultStr: String;
begin
Result := '{pf}\OandA';


if RegQueryStringValue( HKLM, 'Software\Golden Stag
Productions\OandA', 'Path', ResultStr)
then
Result := ResultStr;
end;

--

Ken Mayer [dBVIPS]

unread,
Oct 8, 2008, 9:38:08 PM10/8/08
to
Andrew Shimmin wrote:
>> DefaultDirName=OandADir()
>
> I am not sure I understand your problem correctly, however, the function
> is used in INNO this way:
>
> DefaultDirName={code:OandDir}

Thanks. I will try this first ... the reason for the function is that
the path may not exist in the registry, depending on which version of
the program my users have ...

Ken

Andrew Shimmin

unread,
Oct 9, 2008, 10:25:58 PM10/9/08
to
Ken,

I knew you would figure it out as soon as you decided to figure out how it worked.

regards, andrew

0 new messages