Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Cant read registry entry in MFC using

Posted on 2003-02-19
Medium Priority
Last Modified: 2013-11-20
I am using the following function
     RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentSet\\WebServices\\Netlogon", 0,KEY_READ, &hKey) == ERROR_SUCCESS)
to open the key.
This function returns SUCCESS indicating that it has opened the key. However when I try to read one of the values under this key by using the following function

DWORD DataType ; DWORD DataSize;DWORD lpData;
::RegQueryValueExW(hKey, KEYNAME, NULL, &DataType, ( LPBYTE )&lpData, &DataSize);              

it does nothing the value in lpData remains zero where as the value should be 2.

Any ideas to what might be going wrong.
Question by:vgandhi2003
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
1 Comment

Accepted Solution

Priyesh earned 150 total points
ID: 7984913
Initialize the DataSize variable before you make your call.
if you are querying for a REG_DWORD type, set the DataSize = sizeof(DWORD).

if you want to know the size of data that is to be read, pass the lpData as NULL and look at the value filled in DataSize after the function call.


Featured Post

Industry Leaders: 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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : All lightning effects with instructions : http://www.mediaf…

721 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