News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

read ini and parse string problem

Started by ragdog, February 13, 2007, 10:15:55 PM

Previous topic - Next topic

ragdog

hi @all

i have trouble with read ini and parsing the string

can your help me please

my source is posted

thanks in forward

ragdog

[attachment deleted by admin]

sinsi

GetPrivateProfileString returns 0 if something goes wrong (can't find the ini file, can't find the section, can't find the key).
Your ini file doesn't have a key called "Path", so your buffer doesn't get filled with anything.
       @1:
      mov edi,offset hProfile

should be
      mov edi,offset hProfile
       @1:

or you're never going to get past the first byte in the buffer. It's a good idea to check for a NULL at the end of the string, too.
Light travels faster than sound, that's why some people seem bright until you hear them.

ragdog

thx for your help


I it changed in this algo:

             mov edi,offset hProfile
             inc edi
          inc edi
          inc edi
          inc edi
          inc edi
          cmp byte ptr [edi],0
          jne @print
           je @ret
    @print: 
          invoke lstrcat,addr hbuff,edi
          invoke MessageBox,hWin,addr hbuff ,0,MB_OK
     @ret:

this works ! I have now only one ask whether it am also correct?


sinsi

I'm not sure what you are trying to do here. GetPrivateProfileString will fill your buffer with whatever is after the "=" from the INI file and NULL-terminate it,
so I don't get why you add each character to your own buffer then show it...
    invoke MessageBox,hWin,addr hProfile ,0,MB_OK will do it in one.
Light travels faster than sound, that's why some people seem bright until you hear them.

ragdog

I changed it! I do not point which you mean direct I hope that is correctly


              mov edi,offset hProfile
    @read:
             cmp byte ptr [edi],0
          je @ret
             cmp byte ptr [edi],"/"
             je @print
             inc edi
          jmp @read
    @print: 
               inc edi
          invoke lstrcat,addr hbuff,edi
          invoke MessageBox,hWin,addr hbuff  ,0,MB_OK
     @ret:


greetz
ragdog