Solved

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

Posted on 1998-08-13
4
131 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
[X]
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
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Making delphi communicate with a c# service 16 123
drawing animated level bar based on numbers 3 112
Delphi Seattle StructureView color 1 21
Firemonkey Queue list 1 30
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…

749 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