well basically i want my program to read an ini file first it will get the section names...then it will get the keynames and then the string of each keyname.. but the problem is its gonna be an ini file that i wont know the keynames/sections beforehand
so im trying to figure a good procedure to grab the section names in a buffer <which are supposedly null terminated according to msdn> then ill pass each name to another procedure that gets the keynames in order to get their strings
so anyway this is what i got so far and its not working


ReadINI PROTO
.data
INIname db ".\urls.ini",0
.data?
headBuffer db 256 dup(?)
.code
start:
invoke ReadINI
invoke ExitProcess,0

ReadINI proc
LOCAL Len:DWORD
invoke GetPrivateProfileSectionNames,addr headBuffer,addr Len,ADDR INIname
lea esi, headBuffer
@@:
lodsb
test al, al
jnz @b
mov al, BYTE PTR [esi]
test al, al
jz ListDone
invoke MessageBox,0, esi,addr INIname,0
jmp @b
ListDone:
ret
ReadINI endp
end start


tell me why this ini function does not cycle through the ini names that get stored in the buffer
:stupid:
Posted on 2003-12-25 19:30:33 by illwill
illwill
Wrong second parameter GetPrivateProfileSectionNames. Need sizeof headBuffer.
Your code don't show first section name.
; console app

.386
.model flat, stdcall
option casemap :none

.nolist
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
.list

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.const
INIname db 'c:\winnt\w32dasm8.ini',0
szSmall db 'Buffer is not large enough to contain all the section names',13,10,0
szSectName db '[%s]',13,10,0

.code
;-------------------------------------------------------------------;
even
SimplePrintf proc C, pszFormat, param:VARARG
local buffer[2048]:byte
local hOutPut:dword
local bWritten:dword

invoke wvsprintf, addr buffer, pszFormat, addr param
invoke GetStdHandle,STD_OUTPUT_HANDLE
mov hOutPut,eax
invoke lstrlen,addr buffer
mov ecx,eax
invoke WriteFile, hOutPut, addr buffer, ecx, addr bWritten, NULL
mov eax, bWritten
ret
SimplePrintf endp

;-------------------------------------------------------------------;
even
main proc
local headBuffer[1024]

invoke GetPrivateProfileSectionNames,addr headBuffer, sizeof headBuffer,\
offset INIname
add eax,2
.if eax == sizeof headBuffer
invoke SimplePrintf, offset szSmall
.else
push ebx
lea ebx,headBuffer
.while byte ptr [ebx] != 0
invoke SimplePrintf, offset szSectName, ebx
invoke lstrlen, ebx
inc eax
add ebx,eax
.endw
pop ebx
.endif

ret
main endp

;-------------------------------------------------------------------;
even
_start:
invoke main
invoke ExitProcess,0

end _start
Posted on 2003-12-25 21:23:33 by P2M