🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.delphi.misc
Article #167

Re: get data from Registry

#167
From: Darren Winter
Date: Mon, 07 Jul 1997 00:00
88 lines
3176 bytes


Shay Toder <shayt@inter.net.il> wrote in article
<33BF8946.14BC8A9F@inter.net.il>...
> hi,
> how do I get a data from the registry ?
> I've got the RegOpenKey to open the key, but fhe function brings me
> handle to the key, and i want to get the string i put in a key.
> 
> (if it's not too much trouble Email me plus the newsgroup)
> thanks
> shay
> 

Shay - I hope this helps you out:

I use the read/writestring and read/writebool methods the most.  Here are
some examples:

uses registry;

var reg: tregisrty;

reg:= tregistry.create;
reg.rootkey:= HKEY_CLASSES_ROOT;

//WRITESTRING SYNTAX
//reg.openkey('<key>', true);  //true creates <key> if it does not exist
//reg.writestring('<variable>', '<string>');  //use ('') for <variable> to
write to the DEFAULT varaible in the Registry
//reg.closekey;

//example #1:
reg.openkey('.123', true);
reg.writestring('', '123_auto_file');
reg.closekey;

//example #2:
reg.openkey('123_auto_file', true);
reg.writestring('Hello', 'Hello?');
reg.closekey;

//READSTRING SYNTAX
//reg.openkey('<key>', true);  //true creates <key> if it does not exist
//reg.readstring('<variable>', '<string>');  //use ('') for <variable> to
read from the DEFAULT varaible in the Registry - <string> is a default
value to return if the value of <variable> is empty
//reg.closekey;

//example #1:
reg.openkey('.123', true);
reg.readstring('', '123_auto_file');
reg.closekey;

//example #2:
reg.openkey('123_auto_file', true);
reg.readstring('Hello', 'Hello?');
reg.closekey;

Aside from all of this, I normally set up a string variable in my procedure
to "capture" the returned value:

var s: string;

s:= reg.readstring('Hello', 'Hello?');

This puts the return value from the Registry into <s> for further
processing.

Another example (super-sweet for checkboxes):

checkbox1.checked:= reg.readbool('Hello', false);  //false is the default
result if <hello> is empty

If the value if <hello> in the registry is set to 1, then the returned
result of the READBOOL method would be TRUE and the checkbox would be
checked.  If the value of <hello> is 0 (or empty) the returned result would
be FALSE and the checkbox will not be checked.

I will try to email this to you tonight as well.


Hope this helps!


Darren Winter
dlw@istnet.net
Technical Details
Message-ID: <01bc8aea$68ffb4a0$ec52bbce@ati1>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <33BF8946.14BC8A9F@inter.net.il>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1091e5,eb456324663bca5d
X-Google-Attributes: gid1091e5,public
X-Google-Thread: f973d,eb456324663bca5d
X-Google-Attributes: gidf973d,public
X-Google-Thread: 10baee,eb456324663bca5d
X-Google-Attributes: gid10baee,public
X-Google-Thread: fd817,eb456324663bca5d
X-Google-Attributes: gidfd817,public
X-Google-Thread: 10545b,eb456324663bca5d
X-Google-Attributes: gid10545b,public
From: "Darren Winter" <dlw@istnet.net>
Subject: Re: get data from Registry
Date: 1997/07/07
Message-ID: <01bc8aea$68ffb4a0$ec52bbce@ati1>
X-Deja-AN: 255265079
References: <33BF8946.14BC8A9F@inter.net.il>
Organization: CustomSoft, Inc.
Newsgroups: comp.lang.pascal.delphi.misc,alt.lang.delphi,alt.comp.lang.borland-delphi,borland.public.delphi.ide,borland.public.delphi.winapi