can anyone tell me why this is putting the default string in the buffer? Firstini db 8 dup (0) first db "First",0h ERROR db "ERROR",0h section db "IPs",0h invoke GetPrivateProfileString,ADDR section,ADDR first,ADDR ERROR,ADDR Firstini,8,ADDR inishort i have checked the path and it is correct. the ini file is there and the section name and key are both present. there is data in the key specified (3 bytes). why is it not working??? Please help me. thanks. skud.
Have you checked your return code in eax to see if the function is returning an error code?
yes i have. as i have said the buffer is 8 bytes and the data in the ini file is 3 bytes. i checked the return to see if for some reason it thought that the string was to big and it doesnt. the string is fine. it doesnt tell you in win32.hlp what the returns from GetLastError mean so that is all i can check by the way of returned values. thanks anyway. all feedback appreciated. :P skud.
Skud, I'm not sure if this is your problem or not but... I had a problem with this api the first time I used it as well. The problem was in the lpFileName param. You said that you checked the path and it's correct, but I noticed "ADDR inishort" and thought I'd point it out in case you've got the same problem. The filename param has to be the complete path name for the ini file and not just the short path (as your filename variable's name suggests), unless it's in the windows directory that is. Anyways, that may not even be your problem. 8n) G'luck
this is not the first time i have used this :P i have used it before and it worked fine. however this was in TASM. i used it by doing call ... i also did it again after this and it wouldnt work. i now want to use it again and i still cant get it to work. this time i have to get it to work cos last time i just used the registry in the end. - 4oh4 - you got me thinking and i rearranged some code before the call to GetPrivateProfileString. i managed to get rid of one line but it still doesnt work. i remember that sometime i was using it and it needed the short path (cos its a 16-bit thingy isnt it?) and it worked. anyway, it still dumps the ERROR message in the buffer whether it is the long file name or the short one. here is my code anyway: currentdir db 128 dup (0) inipath db 256 dup (0) inishort db 64 dup (0) firstini db 8 dup (0) ininame db "\IPGen.ini",0 section db "IPs",0 first db "first",0 ERROR db "ERROR",0 invoke GetCurrentDirectory,128,ADDR currentdir invoke lstrcpy,ADDR inipath,ADDR currentdir invoke lstrcat,ADDR inipath,ADDR ininame invoke GetShortPathName,ADDR inipath,ADDR inishort,64 invoke GetPrivateProfileString,ADDR section,ADDR first,ADDR ERROR,ADDR firstini,8,ADDR inishort please, please, please heplp me... thanks. skud.