Solved

How to read Strings (REG_SZ) from Registry?

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

809 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