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. I port my application in vc++ 2005 to vc++ 2008 -registry entry code could not work properly.

I port my application in vc++ 2005 to vc++ 2008 -registry entry code could not work properly.

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++visual-studiowindows-adminhelp
13 Posts 3 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.
  • V Offline
    V Offline
    vicky00000
    wrote on last edited by
    #1

    I port my application in vc++ 2005 to vc++ 2008. it works proper other than registry entry code. Is this is bug of visual studio 2008?

    R 1 Reply Last reply
    0
    • V vicky00000

      I port my application in vc++ 2005 to vc++ 2008. it works proper other than registry entry code. Is this is bug of visual studio 2008?

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

      Have you tried debugging? Did the registry function succeed? Did you checked the return value?

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

      V 1 Reply Last reply
      0
      • R Rajesh R Subramanian

        Have you tried debugging? Did the registry function succeed? Did you checked the return value?

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

        V Offline
        V Offline
        vicky00000
        wrote on last edited by
        #3

        Thanks for your replay. It works in xp But shows problem in vista.

        R 1 Reply Last reply
        0
        • V vicky00000

          Thanks for your replay. It works in xp But shows problem in vista.

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

          vicky00000 wrote:

          It works in xp But shows problem in vista.

          I am sorry, I forgot my telescope today and am unable to see your monitor. Can you please elaborate more on what the problem exactly is? How exactly are you dealing with the registry and what exactly does the registry function returns?

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

          V 1 Reply Last reply
          0
          • R Rajesh R Subramanian

            vicky00000 wrote:

            It works in xp But shows problem in vista.

            I am sorry, I forgot my telescope today and am unable to see your monitor. Can you please elaborate more on what the problem exactly is? How exactly are you dealing with the registry and what exactly does the registry function returns?

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

            V Offline
            V Offline
            vicky00000
            wrote on last edited by
            #5

            Thanks for your replay. I wrote an applcation in vc++ 2005,in which I create a new registry key and set some value. This one work proper in xp and vista. I port the same code to vc++ 2008. It works in xp, but not in vista. I hope you can understand my problem. Thanks.

            R 1 Reply Last reply
            0
            • V vicky00000

              Thanks for your replay. I wrote an applcation in vc++ 2005,in which I create a new registry key and set some value. This one work proper in xp and vista. I port the same code to vc++ 2008. It works in xp, but not in vista. I hope you can understand my problem. Thanks.

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

              vicky00000 wrote:

              I wrote an applcation in vc++ 2005,in which I create a new registry key and set some value. This one work proper in xp and vista. I port the same code to vc++ 2008. It works in xp, but not in vista.

              Aren't you using some function which would create the new registry key? What is that function returning when you say it wasn't working?

              vicky00000 wrote:

              I hope you can understand my problem.

              I bet nobody can.

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

              V 1 Reply Last reply
              0
              • R Rajesh R Subramanian

                vicky00000 wrote:

                I wrote an applcation in vc++ 2005,in which I create a new registry key and set some value. This one work proper in xp and vista. I port the same code to vc++ 2008. It works in xp, but not in vista.

                Aren't you using some function which would create the new registry key? What is that function returning when you say it wasn't working?

                vicky00000 wrote:

                I hope you can understand my problem.

                I bet nobody can.

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

                V Offline
                V Offline
                vicky00000
                wrote on last edited by
                #7

                Thanks for ur replay. long lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE,_T("Some Path"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisposition); lRet is 5 in the case vc++ 2008 and in the case vc++ 2005 lRet is 0

                R M 2 Replies Last reply
                0
                • V vicky00000

                  Thanks for ur replay. long lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE,_T("Some Path"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisposition); lRet is 5 in the case vc++ 2008 and in the case vc++ 2005 lRet is 0

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

                  vicky00000 wrote:

                  lRet is 5 in the case vc++ 2008 and in the case vc++ 2005 lRet is 0

                  The documentation for RegCreateEx says a non-zero value is returned, when the function fails. 5 is a non-zero value AFAIK. The documentation also says: use FormatMessage()[^] with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.

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

                  1 Reply Last reply
                  0
                  • V vicky00000

                    Thanks for ur replay. long lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE,_T("Some Path"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisposition); lRet is 5 in the case vc++ 2008 and in the case vc++ 2005 lRet is 0

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #9

                    I would suspect it's an access denied error since you're writing to HKEY_LOCAL_MACHINE. Your app needs to run with elevated privileges to do that. Mark

                    Mark Salsbery Microsoft MVP - Visual C++ :java:

                    V 1 Reply Last reply
                    0
                    • M Mark Salsbery

                      I would suspect it's an access denied error since you're writing to HKEY_LOCAL_MACHINE. Your app needs to run with elevated privileges to do that. Mark

                      Mark Salsbery Microsoft MVP - Visual C++ :java:

                      V Offline
                      V Offline
                      vicky00000
                      wrote on last edited by
                      #10

                      Mark Salsbery, Yes, this is access denied error, could you please explain how to overcome this problem. Thanks in advance.

                      M 1 Reply Last reply
                      0
                      • V vicky00000

                        Mark Salsbery, Yes, this is access denied error, could you please explain how to overcome this problem. Thanks in advance.

                        M Offline
                        M Offline
                        Mark Salsbery
                        wrote on last edited by
                        #11

                        Writing to HKEY_LOCAL_MACHINE requires the code to run with administrator rights/elevated privileges. Does it work if you run your app as an administrator? Why do you need to write to HKEY_LOCAL_MACHINE?  That should generally only be done at install time (running elevated). If you have common application data that needs to be shared between users, then you should store that at the recommended application shared data folder, not in the registry. Unless, of course, all users of your app have no problem running the app as an administrator. Mark

                        Mark Salsbery Microsoft MVP - Visual C++ :java:

                        V 1 Reply Last reply
                        0
                        • M Mark Salsbery

                          Writing to HKEY_LOCAL_MACHINE requires the code to run with administrator rights/elevated privileges. Does it work if you run your app as an administrator? Why do you need to write to HKEY_LOCAL_MACHINE?  That should generally only be done at install time (running elevated). If you have common application data that needs to be shared between users, then you should store that at the recommended application shared data folder, not in the registry. Unless, of course, all users of your app have no problem running the app as an administrator. Mark

                          Mark Salsbery Microsoft MVP - Visual C++ :java:

                          V Offline
                          V Offline
                          vicky00000
                          wrote on last edited by
                          #12

                          Thanks for your valuable suggetion. With the help of your valuable suggetion i solve my problem by set UAC. please go through the MSDN link [http://msdn2.microsoft.com/en-us/library/bb384691.aspx">http://msdn2.microsoft.com/en-us/library/bb384608.aspx http://msdn2.microsoft.com/en-us/library/bb384691.aspx](http://msdn2.microsoft.com/en-us/library/bb384608.aspx<br mode=) [ [http://msdn2.microsoft.com/en-us/library/bb384691.aspx" target="_blank" title="New Window">^](http://msdn2.microsoft.com/en-us/library/bb384608.aspx<br mode=)] To set this linker option in the Visual Studio development environment Open the project's Property Pages dialog box. Expand the Configuration Properties node. Expand the Linker node. Select the Manifest File property page. Modify the Enable User Account Control (UAC), UAC Execution Level, and UAC Bypass UI Protection properties. To set this linker option programmatically See EnableUAC(), UACExecutionLevel(), and UACUIAccess(). Thanks to all and code project with regards vicky00000

                          M 1 Reply Last reply
                          0
                          • V vicky00000

                            Thanks for your valuable suggetion. With the help of your valuable suggetion i solve my problem by set UAC. please go through the MSDN link [http://msdn2.microsoft.com/en-us/library/bb384691.aspx">http://msdn2.microsoft.com/en-us/library/bb384608.aspx http://msdn2.microsoft.com/en-us/library/bb384691.aspx](http://msdn2.microsoft.com/en-us/library/bb384608.aspx<br mode=) [ [http://msdn2.microsoft.com/en-us/library/bb384691.aspx" target="_blank" title="New Window">^](http://msdn2.microsoft.com/en-us/library/bb384608.aspx<br mode=)] To set this linker option in the Visual Studio development environment Open the project's Property Pages dialog box. Expand the Configuration Properties node. Expand the Linker node. Select the Manifest File property page. Modify the Enable User Account Control (UAC), UAC Execution Level, and UAC Bypass UI Protection properties. To set this linker option programmatically See EnableUAC(), UACExecutionLevel(), and UACUIAccess(). Thanks to all and code project with regards vicky00000

                            M Offline
                            M Offline
                            Mark Salsbery
                            wrote on last edited by
                            #13

                            Awesome! Thanks for the update! Cheers, Mark

                            Mark Salsbery Microsoft MVP - Visual C++ :java:

                            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