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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. multi lines in .ini file how to save and load/read ?

multi lines in .ini file how to save and load/read ?

Scheduled Pinned Locked Moved C / C++ / MFC
csharptutorialquestion
4 Posts 2 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.
  • E Offline
    E Offline
    ELY M
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • E ELY M

      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

      M Offline
      M Offline
      mango_lier
      wrote on last edited by
      #2

      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

      E 1 Reply Last reply
      0
      • E ELY M

        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); } }

        E Offline
        E Offline
        ELY M
        wrote on last edited by
        #3

        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)

        1 Reply Last reply
        0
        • M mango_lier

          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

          E Offline
          E Offline
          ELY M
          wrote on last edited by
          #4

          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); } }

          E 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