Solved

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

Posted on 1998-08-13
4
128 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

772 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