Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem in adding registry entry values

Problem in adding registry entry values

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++windows-adminjsontutorial
11 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    neha agarwal27
    wrote on last edited by
    #1

    Hi all, I am trying to a add a Regitry Entry using MFC api's. Suppose i want to give my program file address to the registry value..... Its not taking full address its just taking 25 characters for example:- C:\Program Files\Data Can anybosy please help me in this.....

    R N C H 4 Replies Last reply
    0
    • N neha agarwal27

      Hi all, I am trying to a add a Regitry Entry using MFC api's. Suppose i want to give my program file address to the registry value..... Its not taking full address its just taking 25 characters for example:- C:\Program Files\Data Can anybosy please help me in this.....

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      neha.agarwal27 wrote:

      I am trying to a add a Regitry Entry using MFC api's.

      Can you please show us the relevant code? Because 1. We can't answer solely on assumptions 2. And there's a pillar right next to your cubicle, so I am not able to see your monitor.

      Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

      1 Reply Last reply
      0
      • N neha agarwal27

        Hi all, I am trying to a add a Regitry Entry using MFC api's. Suppose i want to give my program file address to the registry value..... Its not taking full address its just taking 25 characters for example:- C:\Program Files\Data Can anybosy please help me in this.....

        N Offline
        N Offline
        Nitheesh George
        wrote on last edited by
        #3

        i think u r buffer size may be 25 characters or u r writing only 25 characters

        1 Reply Last reply
        0
        • N neha agarwal27

          Hi all, I am trying to a add a Regitry Entry using MFC api's. Suppose i want to give my program file address to the registry value..... Its not taking full address its just taking 25 characters for example:- C:\Program Files\Data Can anybosy please help me in this.....

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          neha.agarwal27 wrote:

          I am trying to a add a Regitry Entry using MFC api's.

          MFC has an API for the registry? :confused:.

          neha.agarwal27 wrote:

          Suppose i want to give my program file address to the registry value..... Its not taking full address its just taking 25 characters for example:- C:\Program Files\Data

          Be aware that RegSetValueEx's cbData parameter should be the size of the string expressed in bytes, i.e. (string length + 1)*2 for UNICODE strings. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

          N 1 Reply Last reply
          0
          • C CPallini

            neha.agarwal27 wrote:

            I am trying to a add a Regitry Entry using MFC api's.

            MFC has an API for the registry? :confused:.

            neha.agarwal27 wrote:

            Suppose i want to give my program file address to the registry value..... Its not taking full address its just taking 25 characters for example:- C:\Program Files\Data

            Be aware that RegSetValueEx's cbData parameter should be the size of the string expressed in bytes, i.e. (string length + 1)*2 for UNICODE strings. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

            N Offline
            N Offline
            neha agarwal27
            wrote on last edited by
            #5

            Thanks for your reply..... it worked fine with my code.... now my problem is my code is creating registry enteries fine in xp but its not creating it in vista but when i run my program as administrator it creates the enteries.... how can i remove my problem...

            C 1 Reply Last reply
            0
            • N neha agarwal27

              Thanks for your reply..... it worked fine with my code.... now my problem is my code is creating registry enteries fine in xp but its not creating it in vista but when i run my program as administrator it creates the enteries.... how can i remove my problem...

              C Offline
              C Offline
              CPallini
              wrote on last edited by
              #6

              Hence run the program as administrator. :-D Seriously, I don't know. Maybe you'll have more luck on Vista[^] forum. :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

              N 1 Reply Last reply
              0
              • C CPallini

                Hence run the program as administrator. :-D Seriously, I don't know. Maybe you'll have more luck on Vista[^] forum. :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                N Offline
                N Offline
                neha agarwal27
                wrote on last edited by
                #7

                and when i am trying to add binary entry(REG_BINARY), like if i want to add 11 01 10 11 then in registry only 00 00 00 00 is added.... can you tell me the problem

                C 1 Reply Last reply
                0
                • N neha agarwal27

                  and when i am trying to add binary entry(REG_BINARY), like if i want to add 11 01 10 11 then in registry only 00 00 00 00 is added.... can you tell me the problem

                  C Offline
                  C Offline
                  CPallini
                  wrote on last edited by
                  #8

                  Could you please post the relevant code?

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                  N 1 Reply Last reply
                  0
                  • C CPallini

                    Could you please post the relevant code?

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                    N Offline
                    N Offline
                    neha agarwal27
                    wrote on last edited by
                    #9

                    RegCreateKeyEx ( hkey, (LPCTSTR) str1, 0, NULL, REG_OPTION_NON_VOLATILE,
                    KEY_CREATE_SUB_KEY | KEY_ALL_ACCESS, NULL, &childkey, &dispos ) ;

                    RegSetValueEx ( childkey, (LPCTSTR)str2, 0, valur_type, (const BYTE*) (LPCTSTR)str4, (str4.GetLength()+1)*2 ) ;
                    RegCloseKey ( childkey ) ;

                    C 1 Reply Last reply
                    0
                    • N neha agarwal27

                      RegCreateKeyEx ( hkey, (LPCTSTR) str1, 0, NULL, REG_OPTION_NON_VOLATILE,
                      KEY_CREATE_SUB_KEY | KEY_ALL_ACCESS, NULL, &childkey, &dispos ) ;

                      RegSetValueEx ( childkey, (LPCTSTR)str2, 0, valur_type, (const BYTE*) (LPCTSTR)str4, (str4.GetLength()+1)*2 ) ;
                      RegCloseKey ( childkey ) ;

                      C Offline
                      C Offline
                      CPallini
                      wrote on last edited by
                      #10

                      I don't see any REG_BINARY in your code. BTW To maintain generic text mappings, I suggest you to change from (str4.GetLength()+1)*2 to (str4.GetLength()+1) * sizeof(TCHAR) . :)

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                      1 Reply Last reply
                      0
                      • N neha agarwal27

                        Hi all, I am trying to a add a Regitry Entry using MFC api's. Suppose i want to give my program file address to the registry value..... Its not taking full address its just taking 25 characters for example:- C:\Program Files\Data Can anybosy please help me in this.....

                        H Offline
                        H Offline
                        Hamid Taebi
                        wrote on last edited by
                        #11

                        See http://www.codeproject.com/KB/system/caaregistryclass.aspx[^].

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups