FileName = "data/config.ini"
sSTRING = "Screen Width=" & CStr(Width) & Chr(0) & Chr(0)
lRESULT = WritePrivateProfileSection("Display", sSTRING, FileName)
Width = GetPrivateProfileInt("Display", "Screen Width", 0, sFILE) '' crappy things happen here
Where am I going wrong?
/Sandman
INI File I/O
[VISUAL BASIC] I have my little setup app that configures my game''s resolution and so on. I write this info to an INI file, successfully, with the API call WritePrivateProfileSection(). But when I''m to read these values into variables after restarting the app, I get crap data instead of the section data. I then use GetPrivateProfileString() and GetPrivateProfileInt().
For example, I read in the screen width. It gives me something like 83413250813205987132507 which is false It doesn''t even return the default return value I specify...
In no particular order some things of the top of my head:
When you say wrote successfully, do you mean the result code was successful, or did you actually check the ini file was written correctly?
Are you sure you''re opening the same file you wrote to?
Did you try WritePrivateProfileString() instead of WritePrivateProfileSection() ?
Did you try replacing your key name with one without spaces?
When you say wrote successfully, do you mean the result code was successful, or did you actually check the ini file was written correctly?
Are you sure you''re opening the same file you wrote to?
Did you try WritePrivateProfileString() instead of WritePrivateProfileSection() ?
Did you try replacing your key name with one without spaces?
Hey I tried all your ideas now..
It doesn't work. It works in C++ though! The exact same calls. Very weird. What should one do different in VB?
Take the following simple example (nice last two words
AND IN VB:
The C++ version prints 640 which is correct. The VB snippet messages 84783082476 something. Very wrong.
Clueless!!?!++"`%?%"???!?!
/Sandman
[edited by - Saandman on November 9, 2002 5:32:57 PM]
It doesn't work. It works in C++ though! The exact same calls. Very weird. What should one do different in VB?
Take the following simple example (nice last two words
WritePrivateProfileString "Display", "Width", "640", "data/conf.ini");cout << GetPrivateProfileInt("Display", "Width", 0, "data/conf.ini") << endl;
AND IN VB:
WritePrivateProfileString("Display", "Width", "640", "data/conf.ini")MsgBox(GetPrivateProfileInt("Display", "Width", 0, "data/conf.ini"))
The C++ version prints 640 which is correct. The VB snippet messages 84783082476 something. Very wrong.
Clueless!!?!++"`%?%"???!?!
/Sandman
[edited by - Saandman on November 9, 2002 5:32:57 PM]
quote:Original post by elis-cool
VB == crap.. you shouldnt be using it at all! There, your problem is fixed!
What a thoroughly idiotic thing to say. Kudos!
God puts an apple tree in the middle of the Garden of Eden and says, do what you like guys, oh, but don''t eat the apple. Surprise surprise, they eat it and he leaps out from behind a bush shouting "Gotcha." It wouldn''t have made any difference if they hadn''t eaten it... because if you''re dealing with somebody who has the sort of mentality which likes leaving hats on the pavement with bricks under them you know perfectly well they won''t give up. They''ll get you in the end. -- Douglas Adams
displayWidth = GetPrivateProfileInt("Display", "Width", "0", "conf.ini"
MsgBox (displayWidth)
Worked for me, first time I''ve used vb for a while and haven''t touched api stuff before today. Wouldn''t write to a folder called data for some reason (as you do)
MsgBox (displayWidth)
Worked for me, first time I''ve used vb for a while and haven''t touched api stuff before today. Wouldn''t write to a folder called data for some reason (as you do)
Windows will look in the WINDOWS folder if I don''t specify a full search path to the ini file.
const File as string = "conf.ini"
API->"[root]/WINDOWS/conf.ini"
const File as string = "data/conf.ini"
API->"[currdir]/data/conf.ini"
THIS SHIT IS STILL BUGGING ME!!! WHY DO I GET CRAPDATA INSTEAD OF PERFECTLY RETURNED KEY VALUE!??!!
/Sandman
const File as string = "conf.ini"
API->"[root]/WINDOWS/conf.ini"
const File as string = "data/conf.ini"
API->"[currdir]/data/conf.ini"
THIS SHIT IS STILL BUGGING ME!!! WHY DO I GET CRAPDATA INSTEAD OF PERFECTLY RETURNED KEY VALUE!??!!
/Sandman
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement