Solved

How to read Strings (REG_SZ) from Registry?

Posted on 1998-06-25
4
948 Views
Last Modified: 2010-04-04
Hi...

I already found out, how to write a String or better spoken,
a pChar to the WinRegistry (win95). But how life is...I'm unable to read it back later... And if you are already there, how does that work with numeric/binary types ? Like I said, all I can do yet, is to create my own Keys and set REG_SZ - Values. It also seems, there are some Keywords, like "DefaultIcon", "ShellNew", etc. could u tell me what keyword does what job ?

Thanx, :)
0
Comment
Question by:omsec
  • 2
4 Comments
 
LVL 3

Expert Comment

by:vladika
ID: 1355693
Use class TRegistry and its metods.
For reading use OpenKey then ReadString
See in help full information about TRegistry

0
 
LVL 2

Author Comment

by:omsec
ID: 1355694
sorry, dude i expected some source for these points
0
 
LVL 4

Accepted Solution

by:
d003303 earned 70 total points
ID: 1355695
uses Registry;

procedure WriteToReg(Key, ValueName, Value : string);
var Registry : TRegistry;
begin
  Registry := TRegistry.Create;
  try
    Registry.RootKey := HKEY_CLASSES_ROOT; // for example
    Registry.OpenKey(Key, true);
    // you could also use WriteBinaryData, WriteBool, WriteCurrency, WriteDate, WriteDateTime, WriteFloat, WriteInteger, WriteTime
    Registry.WriteString(ValueName, Value);
  finally
    Registry.Free;
  end;
end;

function ReadFromReg(Key, ValueName : string): string;
var Registry : TRegistry;
begin
  Registry := TRegistry.Create;
  Result := '';
  try
    Registry.RootKey := HKEY_CLASSES_ROOT; // for example
    if Registry.OpenKey(Key, true) then
    // you could also use ReadBinaryData, ReadBool, ReadCurrency, ReadDate, ReadDateTime, ReadFloat, ReadInteger, ReadTime
     Result := Registry.ReadString(ValueName);
  finally
    Registry.Free;
  end;
end;

Slash/d003303
0
 
LVL 4

Expert Comment

by:d003303
ID: 1355696
For the meaning of the keywords you mentioned, take a look at the Microsoft Knowledge Base at
http://www.microsoft.com/win32dev/uiguide/uigui255.htm
for a description of the W95 registry.

Slash/d003303
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
proper way to parse url in delphi 2 160
Newbie Thread Programming 1 138
How to debug For loops? 3 45
Performance of SQL statement 37 95
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now