Solved

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

Posted on 1998-08-13
4
127 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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 Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 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

11 Experts available now in Live!

Get 1:1 Help Now