Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Reading Registry - easy..... I think.

Posted on 1998-08-13
4
129 Views
Last Modified: 2010-04-04
Here's the deal........ I've done many registry reads, writes, etc..., without a problem......
but I am now trying to read the value "[Default]" or "(Default)" as many of the applications
have listed for a directory install. (This value is just about everywhere in the registry).

I thought this would be just like any other read, but I can't seem to get this value.
For example,
    If the registry has 2 values to extract (after opening the key) and the only 2 values are
    [Default]
    Path

    If I plug this readstring command into my code:
    Temp_Str  := ReadString('Path');
    then my code will execute fine and get the value.
    If I replace the same string with:
    Temp_Str  := ReadString('[Default]');
    then it won't return anything....... even though both "Path" and "Default" contain strings.
    It has to be possible to read this, anyone know what I'm missing here?  I tried (Default) thinking
    that I was misinterpreting the ending characters, but that doesn't work either.

                        Thanks
0
Comment
Question by:jexd99
  • 2
  • 2
4 Comments
 
LVL 20

Accepted Solution

by:
Madshi earned 50 total points
ID: 1362072
Sample:
HKEY_LOCAL_MACHINE\Software\SampleKey\(Default)
Now do NOT the following:
OpenKey("HKEY_LOCAL_MACHINE\Software\SampleKey");
ReadVal("(Default)");
But do the following:
OpenKey("HKEY_LOCAL_MACHINE\Software");
ReadVal("Software\"); or ReadVal("Software");
0
 

Author Comment

by:jexd99
ID: 1362073
What is specified above won't work, as there could be many subkeys listed besides "samplekey" (I probably didn't specify this clear enough).  I need the value for (Default)......
For example, for wordpad,  if [Default] is "c:\mydir" and it is located at  

Software\Microsoft\Windows\CurrentVersion\App Paths\Wordpad.exe\[Default] then

       If OpenKey('Software\Microsoft\Windows\CurrentVersion\App Paths\Wordpad.exe',                         False) then
            Test := ReadString('[Default]');
            closekey;
       end;

will not work, but any other subkeys besides "[Default]" works fine and returns a string, but I can't get the string at [Default]  (I've tried [] and () around it......)
?
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1362074
Ooops. Perhaps I should try my suggestions before answering...

Now I tried it out and what you have to do is:

       If OpenKey('Software\Microsoft\Windows\CurrentVersion\App Paths\Wordpad.exe',False) then
            Test := ReadString('');
            closekey;
       end;

It's a little bit strange, isn't it? But it works...
0
 

Author Comment

by:jexd99
ID: 1362075
Wow, that is strange.  It figures that this isn't specified anywhere.  Maybe if I would have bought the $15 help section upgrade in D3, this would have been covered. :-)
Thanks, just glad to see that this now works !!! :-)
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

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

829 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