?
Solved

please help me with writing Registry

Posted on 2002-07-26
3
Medium Priority
?
183 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
[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
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 320 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

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