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. Storing variables in a program

Storing variables in a program

Scheduled Pinned Locked Moved C / C++ / MFC
security
11 Posts 4 Posters 1 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.
  • I Offline
    I Offline
    ixcaliber
    wrote on last edited by
    #1

    I have a dialog box application that I would like to remember some strings that i type in for the next time the program starts... I don't want to just write them to a text file for obvious security problems, i was thinking more like writing them to a string table, but i don't know if i can do that while the program is running rather than while programming it... Any suggestions will be greatly appreciated and i can give more information if need be. thx ix

    P O I 4 Replies Last reply
    0
    • I ixcaliber

      I have a dialog box application that I would like to remember some strings that i type in for the next time the program starts... I don't want to just write them to a text file for obvious security problems, i was thinking more like writing them to a string table, but i don't know if i can do that while the program is running rather than while programming it... Any suggestions will be greatly appreciated and i can give more information if need be. thx ix

      P Offline
      P Offline
      palbano
      wrote on last edited by
      #2

      First, depending on who you are securing the data from, string tables are no more secure than a text file. Second, security is a large complex issue, you should read much about it before you begin to assume what is secure. Third, you cannot write the resources of a file that is currently loaded.

      "No matter where you go, there your are." - Buckaroo Banzai

      -pete

      1 Reply Last reply
      0
      • I ixcaliber

        I have a dialog box application that I would like to remember some strings that i type in for the next time the program starts... I don't want to just write them to a text file for obvious security problems, i was thinking more like writing them to a string table, but i don't know if i can do that while the program is running rather than while programming it... Any suggestions will be greatly appreciated and i can give more information if need be. thx ix

        O Offline
        O Offline
        OBRon
        wrote on last edited by
        #3

        The registry is the best place to house this sort of information. If security is that important though, you could always encrypt your data before writing it.

        1 Reply Last reply
        0
        • I ixcaliber

          I have a dialog box application that I would like to remember some strings that i type in for the next time the program starts... I don't want to just write them to a text file for obvious security problems, i was thinking more like writing them to a string table, but i don't know if i can do that while the program is running rather than while programming it... Any suggestions will be greatly appreciated and i can give more information if need be. thx ix

          I Offline
          I Offline
          ixcaliber
          wrote on last edited by
          #4

          I guess i should clarify, security isn't that important, really i just don't want to have a text file with the strings in it... Its for an ftp program, where you can write in lots of different usernames and passwords so it remembers them all for next time... the registry is where i do that? thanx for the replys.

          O P 2 Replies Last reply
          0
          • I ixcaliber

            I guess i should clarify, security isn't that important, really i just don't want to have a text file with the strings in it... Its for an ftp program, where you can write in lots of different usernames and passwords so it remembers them all for next time... the registry is where i do that? thanx for the replys.

            O Offline
            O Offline
            OBRon
            wrote on last edited by
            #5

            Yep, just about every application that remembers the application options and various settings stores that information in the registry.

            I 1 Reply Last reply
            0
            • O OBRon

              Yep, just about every application that remembers the application options and various settings stores that information in the registry.

              I Offline
              I Offline
              ixcaliber
              wrote on last edited by
              #6

              Hey thanks alot folks... thats an amazingly fast answer to my problem!!! now i gonna have to learn some more stuff :-D

              1 Reply Last reply
              0
              • I ixcaliber

                I guess i should clarify, security isn't that important, really i just don't want to have a text file with the strings in it... Its for an ftp program, where you can write in lots of different usernames and passwords so it remembers them all for next time... the registry is where i do that? thanx for the replys.

                P Offline
                P Offline
                palbano
                wrote on last edited by
                #7

                >> where you can write in lots of different >> usernames and passwords >> the registry is where i do that? If this is going to be a production product then I would seriously advise against that. Storing passwords a clear text anywhere is not going to be considered acceptable. As I stated previously, security is a large subject, you can't really know until you start to investigate it. There are so many resources available these days on the net for reading about software security issues. You really should take some time to understand the subject more thoroughly. But, that's just my opinion… I could be wrong.

                "No matter where you go, there your are." - Buckaroo Banzai

                -pete

                J 1 Reply Last reply
                0
                • I ixcaliber

                  I have a dialog box application that I would like to remember some strings that i type in for the next time the program starts... I don't want to just write them to a text file for obvious security problems, i was thinking more like writing them to a string table, but i don't know if i can do that while the program is running rather than while programming it... Any suggestions will be greatly appreciated and i can give more information if need be. thx ix

                  I Offline
                  I Offline
                  ixcaliber
                  wrote on last edited by
                  #8

                  Does anyone know a good site for learning how to edit the registry from inside a program? thx

                  O 1 Reply Last reply
                  0
                  • I ixcaliber

                    Does anyone know a good site for learning how to edit the registry from inside a program? thx

                    O Offline
                    O Offline
                    OBRon
                    wrote on last edited by
                    #9

                    The CRegKey class is what you want to use: // Read a DWORD from the registry DWORD dwValue = 0; CString csKEY = "Software\\Company"; CRegKey key; if ( key.Open(HKEY_LOCAL_MACHINE, csKEY, KEY_READ) == ERROR_SUCCESS) { if (key.QueryDWORDValue("MyKey", dwValue) == ERROR_SUCCESS) AfxMessageBox("You read it into dwValue"); key.Close(); } // Write a DWORD to the registry DWORD dwValue = 3; CString csKEY = "Software\\Company"; CRegKey key; if ( key.Create(HKEY_LOCAL_MACHINE, csKEY) == ERROR_SUCCESS) { if (key.SetDWORDValue("MyKey", dwValue) == ERROR_SUCCESS) AfxMessageBox("You wrote it"); key.Close(); }

                    I 1 Reply Last reply
                    0
                    • O OBRon

                      The CRegKey class is what you want to use: // Read a DWORD from the registry DWORD dwValue = 0; CString csKEY = "Software\\Company"; CRegKey key; if ( key.Open(HKEY_LOCAL_MACHINE, csKEY, KEY_READ) == ERROR_SUCCESS) { if (key.QueryDWORDValue("MyKey", dwValue) == ERROR_SUCCESS) AfxMessageBox("You read it into dwValue"); key.Close(); } // Write a DWORD to the registry DWORD dwValue = 3; CString csKEY = "Software\\Company"; CRegKey key; if ( key.Create(HKEY_LOCAL_MACHINE, csKEY) == ERROR_SUCCESS) { if (key.SetDWORDValue("MyKey", dwValue) == ERROR_SUCCESS) AfxMessageBox("You wrote it"); key.Close(); }

                      I Offline
                      I Offline
                      ixcaliber
                      wrote on last edited by
                      #10

                      Man you folks are awesome! that looks just like what i need... a bitto fanagling and it should be perfect!! thx

                      1 Reply Last reply
                      0
                      • P palbano

                        >> where you can write in lots of different >> usernames and passwords >> the registry is where i do that? If this is going to be a production product then I would seriously advise against that. Storing passwords a clear text anywhere is not going to be considered acceptable. As I stated previously, security is a large subject, you can't really know until you start to investigate it. There are so many resources available these days on the net for reading about software security issues. You really should take some time to understand the subject more thoroughly. But, that's just my opinion… I could be wrong.

                        "No matter where you go, there your are." - Buckaroo Banzai

                        -pete

                        J Offline
                        J Offline
                        John M Drescher
                        wrote on last edited by
                        #11

                        I agree this is definitly an area where security is a must and the data must be encrypted. Storing unencrypted values in the registry is not much better than storing them in a file named passwords... John

                        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