Solved

please help me with writing Registry

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 106
Turn a spreadsheet into a vba executable. 2 79
Shell script to login to remote m/c and execute commands 10 78
how to split multiple lines delimiter : 8 80
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

28 Experts available now in Live!

Get 1:1 Help Now