Saving data/settings in a program without a separate data file

I have a program built with VC++ 6.0.  I have an array of data, that I would like the user to be able to change, and have it saved for next time the program is run, without having a seperate data file.

How do I do this?

thanks
galneweinhawAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jaime OlivaresSoftware ArchitectCommented:
If I understand correctly, you don't want to save data in a separate file but in the same .exe file.
This is not a good practice although it is possible to do with "resources", you can't modify resources in a .exe file that is currently running.
Another alternative is to store in registry, but this is not recommended for large amounts of data, normally this technique is used to store "user preferences".
So you can tell us a little more about the data you want to store.
0
galneweinhawAuthor Commented:
Thanks,

Yes, you understand correctly what I'd like to do.

These are settings that would change rarely.  The settings would be  stored, preferably in a single or multiple arrays say 20x5 or something.  I could just do it in a seperate file if it is very difficult.

0
Jaime OlivaresSoftware ArchitectCommented:
If data is short I suggest you to store it in Windows registry. Do you have a sample of your data?
Again I don't recommend you to store in the .exe file.

Windows registry is not a separated file, just a big file with all windows (and applications') configuration. Is the proper site to store config information, but not large data as I told you.
I you decide to store in Windows Registry, you can use some helper class to acomplish that.
Have a look to these at codeproject.com:
http://www.codeproject.com/system/simple_registry.asp
http://www.codeproject.com/system/akregistryex.asp
http://www.codeproject.com/system/registryvars.asp
http://www.codeproject.com/system/registry_class.asp

If you are working with arrays, I suggest you to convert you array information in a comma-separated string, before putting it in a registry entry.

Good luck,
Jaime.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jaime OlivaresSoftware ArchitectCommented:
0
aquila98Commented:
why is it difficult?

a simple .ini file (encypted if you must hide the data) should do:
void ReadOptions()
unsigned long success;
char ret[2048];
DWORD nSize= 2047;
...
memset(ret, 0, nSize);
success= GetPrivateProfileString("SayForInstance:Dimension", "Rows", "0", ret, nSize, m_IniFilePath);
rowcount = atol(ret);
success= GetPrivateProfileString("SayForInstance:Dimension", "Columns", "0", ret, nSize, m_IniFilePath);
colcount = atol(ret);
for (int row= 0; row< rowcount; row++)
{
  for (int col= 0; col< colcount; col++)
  {
      tmp.Format("Cell%d-%d", row,col);
      memset(ret, 0, nSize);
      success= GetPrivateProfileString("Data", tmp, "", ret, nSize, m_IniFilePath);
      if (strlen(ret) > 1)
     {
              put the data in your code somewhere!
             CellsValue[row][col]= ret;
     }
  }
}

and to write the ini:
WritePrivateProfileString("SayForInstance:Dimension", "Columns", "20", m_IniFilePath)
WritePrivateProfileString("SayForInstance:Dimension", "Rows", "5", m_IniFilePath)
for (int row= 0; row< rowcount; row++)
{
  for (int col= 0; col< colcount; col++)
  {
      tmp.Format("Cell%d-%d", row,col);
      WritePrivateProfileString("Data", tmp, CellsValue[row][col], m_IniFilePath)
  }
}

:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.