Solved

please help me with writing Registry

Posted on 2002-07-26
3
180 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 49
Add content to output file 4 67
CRON statement to run every 3 minutes except on Monday morning 12am to 2am 7 103
FizzBuzz challenge 9 82
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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

830 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