Solved

please help me with writing Registry

Posted on 2002-07-26
3
177 Views
Last Modified: 2013-11-20
Hi,Experts:
   I have problems regarding regstry, please give me your help.

   I can create a registry key, but can't set string value to it, my coding is like following;

--

        //here szKey="Software\\testReg\\MyLoginkey1"
     dwErr = RegCreateKeyEx( HKEY_CLASSES_ROOT,
     szKey,
     0,
     "",
     REG_OPTION_NON_VOLATILE,
     KEY_WRITE || KEY_QUERY_VALUE || KEY_READ,
     NULL,
     &hkey,
     &dwDisp);

     if (dwErr != ERROR_SUCCESS) {
          //MessageBox(0,"Failed","Failed",0);
          bRet = FALSE;
     }

       if (dwDisp == REG_CREATED_NEW_KEY ) {


          // Set the registry values as REG_DWORD
          /*
          RegSetValueEx(hkey,
          "MyValueName0",    
          0,
          REG_DWORD,
          (BYTE*)&num,
          sizeof(num));
          */
         

          // Set the registry values as REG_SZ
          RegSetValueEx(hkey,
          "MyValueName1",    
          0,
          REG_SZ,
          (BYTE*)szRegValue1, //char* szRegValue1="Test"
          sizeof(*szRegValue1));

          bRet = TRUE;
     }


     // Finished with key
     RegCloseKey(hkey);

--

  please help me urgently, thank you very much!

-- pigangel


0
Comment
Question by:pigangel
  • 2
3 Comments
 

Author Comment

by:pigangel
ID: 7179637
I found out the problem :I had used KEY_WRITE to created, and after that I change to  KEY_WRITE || KEY_QUERY_VALUE || KEY_READ to order to Query Value and create Value1.

sorry for posting this stupid question.

-- pigangel
   
0
 
LVL 32

Accepted Solution

by:
jhance earned 80 total points
ID: 7179747
Use:

KEY_ALL_ACCESS

instead of the:

KEY_WRITE || KEY_QUERY_VALUE || KEY_READ

mess.  

And besides that, it must be:

KEY_WRITE | KEY_QUERY_VALUE | KEY_READ

The "||" operator is LOGICAL OR where the "|" operator is the BITWISE OR.
0
 

Author Comment

by:pigangel
ID: 7184165
thank you Jhance. thanks for telling me other problem in my coding, it is good to recieve this kind of answer/comment for continuing improvement.

-pigangel
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

23 Experts available now in Live!

Get 1:1 Help Now