Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need a simple way to Write and Read from an INI files. I'm having trouble reading the section headdings E.G; [section1]. How would i b able to go to a section then read a vale E.G: value1=1 (so i want to read "1"). I've found some classes that say they make it quite easy but could not get them to work.
I have done some looking around and have found the GetPrivateProfileString may be able to read values.
Thanks

Why not just read the file and scan it in memory;
Something likeHANDLE hFile CreateFile (blabla, OPEN_EXISTING, blabla);
DWORD Size=GetFileSize(hFile);
BYTE* Buf=(BYTE*)VirtualAlloc(blabla,Size,blabla);
ReadFile(blabla, Buf, Size, blabla);
int l=0;
while ((l<Size)&(lstrcmpi(Buf+l,"[section]")) l++;
l+=lstrlen("[section]");while ((l<Size)&(lstrcmpi(Buf+l,"value1=")) l++;
l+=lstrlen("value1=");int l2=l
while ((l2<Size)&(lstrcmpi(Buf+l2,"\r\n")) l2++;
Buf[l2]=0;
char Result[512];
lstrcpy(Result,Buf+l);
Geddi

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |