HoW To Set registry value in HKLM using c programm

This is a discussion on HoW To Set registry value in HKLM using c programm within the Windows Programming forums, part of the Platform Specific Boards category; i new in program , i need help,, how to add registry value in HKLM. this is my code Code: ...

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    4

    HoW To Set registry value in HKLM using c programm

    i new in program , i need help,, how to add registry value in HKLM.

    this is my code

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <windows.h>
    int main()
    {
        HKEY hkey;
        LONG lreg;
        LONG lres; 
        DWORD dwvalue = 0;
       
        printf("change registry key \n"); 
        
    lreg= RegCreateKeyEx(HKEY_LOCAL_MACHINE, /* reg key */
                   "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI\\Background", /* key to set */
                   0,NULL,REG_OPTION_VOLATILE,KEY_ALL_ACCESS,
                   NULL,&hkey,NULL); 
                   if(lreg ==ERROR_SUCCESS) {
                           printf("success\n");}
                   {
                          
                           lres = RegSetValueEx(hkey,"whatever",0,REG_DWORD,(BYTE*)&dwvalue, sizeof(dwvalue)); /* what ever just trying only */
                         
                        if(lres ==ERROR_SUCCESS){
                                printf("sucess"); 
                                }
                          }
                         
                   
      RegCloseKey(hkey);
      system("PAUSE>nul");    
      return 0;
    }

    please help me

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    Maybe you would learn more if you also printed out the ERROR paths, as well as the error codes.

    "success" or a blank screen are hardly informative.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    4
    this program can print successfully but the registry does not have the value.

  4. #4
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Are you sure the key hasn't been changed? If you're looking at it with RegEdit, make sure you hit refresh (in the view menu I think). If it really hasn't changed, maybe you don't have access.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  5. #5
    Registered User
    Join Date
    Mar 2012
    Posts
    4
    Quote Originally Posted by oogabooga View Post
    Are you sure the key hasn't been changed? If you're looking at it with RegEdit, make sure you hit refresh (in the view menu I think). If it really hasn't changed, maybe you don't have access.

    yes the value does not change. if i chnge HKLM to HKCU it's working,, but i wnt change at HKLM.

  6. #6
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    287
    Are you creating a 32bit application and running it under 64 bit? If yes you will have to access it through the subkey 'Wow6432Node', that is "SOFTWARE\\Wow6432Node\\Microsoft\\.."

    Hope that helps
    Niara

  7. #7
    Registered User
    Join Date
    Mar 2012
    Posts
    4
    Quote Originally Posted by Niara View Post
    Are you creating a 32bit application and running it under 64 bit? If yes you will have to access it through the subkey 'Wow6432Node', that is "SOFTWARE\\Wow6432Node\\Microsoft\\.."

    Hope that helps
    Niara

    Thanks for helping Niara.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Plz help me C programm
    By ferroz1 in forum C Programming
    Replies: 7
    Last Post: 05-10-2008, 06:55 AM
  2. Which programm should I use to ...
    By samus535 in forum Game Programming
    Replies: 3
    Last Post: 10-04-2005, 11:43 AM
  3. help me with this programm
    By a.christodoulou in forum C++ Programming
    Replies: 1
    Last Post: 11-30-2002, 03:50 AM
  4. C:How to programm
    By datainjector in forum C Programming
    Replies: 2
    Last Post: 09-01-2002, 07:35 PM
  5. I am looking for a programm!
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 04-10-2002, 11:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21