Solved

RegQueryValueEx

Posted on 1997-11-16
1
306 Views
Last Modified: 2010-04-04
I can't seem to get this function work properly.
Can anyone give me an example (including variabledeclaration) to get the value from HKEY_LOCAL_MACHINE\SOFTWARE\MYCOMP\MYAppl\WorkingDir ?
0
Comment
Question by:lizzzard
1 Comment
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 50 total points
ID: 1350678
Hi

Here is an example which reads the content of the "CommonFilesDir" value under "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion"

procedure TForm1.Button1Click(Sender: TObject);
var
  hReg: Integer;
  dwType, BufSize: DWORD;
  pBuf: array[0..MAX_PATH] of Char;
begin
  if RegOpenKey(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\CurrentVersion', hReg) = ERROR_SUCCESS then begin
    BufSize := MAX_PATH;
    RegQueryValueEx(hReg, 'CommonFilesDir', nil, @dwType, @pBuf, @BufSize);
    if (dwType = REG_SZ) then ShowMessage(string(PChar(@pBuf)));
    RegCloseKey(hReg);
  end;
end;

Regards,
JB
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
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…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

919 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

19 Experts available now in Live!

Get 1:1 Help Now