The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on February 13, 2007, 10:15:55 PM

Title: read ini and parse string problem
Post by: ragdog on February 13, 2007, 10:15:55 PM
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]
Title: Re: read ini and parse string problem
Post by: sinsi on February 14, 2007, 01:06:12 AM
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.
Title: Re: read ini and parse string problem
Post by: ragdog on February 14, 2007, 01:51:48 AM
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?

Title: Re: read ini and parse string problem
Post by: sinsi on February 14, 2007, 02:09:32 AM
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.
Title: Re: read ini and parse string problem
Post by: ragdog on February 14, 2007, 04:04:25 AM
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