News:

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

incrementing numbers to get ini key names

Started by ChillyWilly, September 17, 2010, 06:27:56 AM

Previous topic - Next topic

ChillyWilly

I have an .ini file that is setup like this

[User000]
name=bob
[User001]
name=sara
[User002]
name=mike
[User003]
name=fred
[Accounts]
number=4


I use GetPrivateProfileString to get the number of accounts which is ascii "4"
I need to loop through the user names(key names) by incrementing USER000 to User001 and calling GetPrivateProfileString with the key name as user000,user001, etc...

i need a quick and dirty way to loop using the returned ascii account number, which in this case would be 4 loops

then append a 0,1,2,3,etc... to the end of "User00" and call GetPrivateProfileString for each user000,user001,user002,etc...

ChillyWilly

 :boohoo: ended up figuring it out so ill post it here just in case someone else has this issue  :cheekygreen:


GetINISections PROC
    local IniSectionNames[1024]

    invoke GetPrivateProfileSectionNames,addr IniSectionNames, sizeof IniSectionNames,CTEXT(".\accounts.ini")
    add eax,2
    push ebx
      lea ebx,IniSectionNames
.while byte ptr [ebx] != 0
        push ebx
invoke GetPrivateProfileString, ebx,CTEXT("name"),CTEXT("No Name Saved"), ADDR account, 128,CTEXT(".\accounts.ini")
invoke RtlZeroMemory,addr account,sizeof account
invoke MessageBox,0,ADDR account,CTEXT("Account Name"),0
        pop ebx
        invoke lstrlen, ebx
        inc eax
        add ebx,eax
.endw
ret
GetINISections EndP



ragdog

For increment the number of this string user000
use Wsprintf and a loop


push edi
mov edi,0
@@:

.while edi<5
   invoke wsprintf, addr hBuff , CTEXT ("User%03u"), edi
   invoke MessageBox,hWnd,addr hBuff,0,MB_OK
   inc edi
    .endw
   pop edi


Is only a quick example!

I hope it help.

Greets,