External DLL calls
BlitzPlus Forums/BlitzPlus Programming/External DLL calls
| ||
I added a Kernel32.desc file in my userlibs sub-directory. It has the following in it: .lib "Kernel32.dll" GetVersionEx%(lpOSVersionInfo*):"GetVersionExA" GetPrivateProfileString%(sectionName$,keyName$,default$,retStr$,bufSize%,fileName$):"GetPrivateProfileStringA" WritePrivateProfileString%(sectionName$,keyName$,strValue$,fileName$):"WritePrivateProfileStringA" The WritePrivateProfileString call works great. However, the GetPrivateProfileString call seems to be failing. I am calling it like this in B+: Const kTileWidth = 64 Local tileWidth$ GetPrivateProfileString( "GameDefs", "TileWidth", Str( kTileWidth ), tileWidth$, 16, "Game.ini" ) This always returns "" Why doesn't this work? I am guessing the 5th parameter size is screwing things up. It should be a DWORD and I am passing an integer. Not sure if they are the same size for B+. |
| ||
The Return Type in the Decls File is '%' there. if your wanting it to return a string, changing it to '$' might help. |
| ||
Actually the Win32 function returns an INT not a string, hence the % in the return type decls file. The string value is set in the 4th parameter. That parameter is a string with enough space allocated to hold the return string. |
| ||
for B+, you can initialize the string you are passing in retStr$ by setting it to a certain # of spaces. so for your example, you can set tileWidth$=" " and then you should start getting back values. im not sure the ramifications of this though since in theory its not supposed to work. the proper way to do it is to use a bank for retStr$ instead of a string. you can see some working declarations at: kernel32.dll decls for INI access i will see if i can post the function i use for reading when i get home. GMan |
| ||
i added my INI access functions at: more INI funcs hope they give you what you need. GMan |
| ||
Your Ini routines work great. Thanks! |