Solved

How to read Strings (REG_SZ) from Registry?

Posted on 1998-06-25
4
955 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

813 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

17 Experts available now in Live!

Get 1:1 Help Now