Solved

please help me with writing Registry

Posted on 2002-07-26
3
181 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 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

739 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