multi lines in .ini file how to save and load/read ?
-
I am working on this little clock program and I added notepad to it. I wanted it to save notepad text to its one ini file [BOX1] Title=test1 remeber me Hour=10 Minutes=1 AM_PM=PM [BOX2] Title=test2 Hour=3 Minutes=4 AM_PM=PM [BOX3] Title=test3 Hour=5 Minutes=6 AM_PM=PM [BOX4] Title=test4 Hour=0 Minutes=0 AM_PM=AM [BOX5] Title=test5 Hour=0 Minutes=0 AM_PM=AM [BOX6] Title=test6 Hour=0 Minutes=0 AM_PM=AM [NOTEPAD] note=dfsdfasdjf fksjflasd;f df;alsdf;ladsf MY COOL NOTE PAD !!!!!! when you open it again after you close it you only see dfsdfasdjf I know I need to add note1= note2= note3= note4= here is my screenshot http://dasher.psychz.net/~area51/notepadclock.jpg
-
I am working on this little clock program and I added notepad to it. I wanted it to save notepad text to its one ini file [BOX1] Title=test1 remeber me Hour=10 Minutes=1 AM_PM=PM [BOX2] Title=test2 Hour=3 Minutes=4 AM_PM=PM [BOX3] Title=test3 Hour=5 Minutes=6 AM_PM=PM [BOX4] Title=test4 Hour=0 Minutes=0 AM_PM=AM [BOX5] Title=test5 Hour=0 Minutes=0 AM_PM=AM [BOX6] Title=test6 Hour=0 Minutes=0 AM_PM=AM [NOTEPAD] note=dfsdfasdjf fksjflasd;f df;alsdf;ladsf MY COOL NOTE PAD !!!!!! when you open it again after you close it you only see dfsdfasdjf I know I need to add note1= note2= note3= note4= here is my screenshot http://dasher.psychz.net/~area51/notepadclock.jpg
Two solutions: 1) Keep the file nmae in the ini file and save the actual text seperate file 2) Use WritePrivateProfileStruct/GetPrivateProfileStruct. 3) is what you suggested above
-
Im not sure how to do WritePrivateProfileStruct so here the code section. not sure if i should add loop or not. think the program will ended up in a loop void CMyDigClockDlg::OnSavenote() { char sIniFile[MAX_PATH]; GetModuleFileName( NULL, sIniFile, MAX_PATH ); strcpy( strrchr( sIniFile, '\\' ) + 1, "reminderclock.ini" ); char notepad[MAX_PATH]; int loop; CString temp_key; assert(m_notepad); ///WritePrivateProfileString ("NOTEPAD", "note", m_notepad, sIniFile); for (loop = 0; loop < m_notepad.Get; ++loop) { temp_key.Format ("note%2.2d", loop); WritePrivateProfileStruct ("NOTEPAD", temp_key, (void *)&m_notepad, sizeof(notes), sIniFile); } }
ERRORS: Compiling... MyDigClockDlg.cpp C:\-= My Stuff =-\-= programs =-\-= MY CLOCKS =-\MyDigClockTest\MyDigClockDlg.cpp(853) : error C2065: 'assert' : undeclared identifier C:\-= My Stuff =-\-= programs =-\-= MY CLOCKS =-\MyDigClockTest\MyDigClockDlg.cpp(856) : error C2039: 'Get' : is not a member of 'CString' c:\-= my software =-\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString' C:\-= My Stuff =-\-= programs =-\-= MY CLOCKS =-\MyDigClockTest\MyDigClockDlg.cpp(863) : error C2065: 'notes' : undeclared identifier Error executing cl.exe. MyDigClock.exe - 3 error(s), 0 warning(s)
-
Two solutions: 1) Keep the file nmae in the ini file and save the actual text seperate file 2) Use WritePrivateProfileStruct/GetPrivateProfileStruct. 3) is what you suggested above
Im not sure how to do WritePrivateProfileStruct so here the code section. not sure if i should add loop or not. think the program will ended up in a loop void CMyDigClockDlg::OnSavenote() { char sIniFile[MAX_PATH]; GetModuleFileName( NULL, sIniFile, MAX_PATH ); strcpy( strrchr( sIniFile, '\\' ) + 1, "reminderclock.ini" ); char notepad[MAX_PATH]; int loop; CString temp_key; assert(m_notepad); ///WritePrivateProfileString ("NOTEPAD", "note", m_notepad, sIniFile); for (loop = 0; loop < m_notepad.Get; ++loop) { temp_key.Format ("note%2.2d", loop); WritePrivateProfileStruct ("NOTEPAD", temp_key, (void *)&m_notepad, sizeof(notes), sIniFile); } }