IonicWind Software

IWBasic => Console Corner => Topic started by: REDEBOLT on June 16, 2008, 04:11:31 PM

Title: PrivateProfileString
Post by: REDEBOLT on June 16, 2008, 04:11:31 PM
I am trying to get my arms around "WritePrivateProfileString" without success.
What am I doing wrong?

I haven't been able to find any examples.

' Create the "ini" file for graphics.
'
'$INCLUDE "windows.inc"
$INCLUDE "typedefs.inc"
DECLARE IMPORT,WritePrivateProfileString alias WritePrivateProfileStringA(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpString, LPCWSTR lpFileName),BOOL
DECLARE IMPORT, _GetLastError ALIAS GetLastError(),INT

GLOBAL CreateIni
DEF inifile as file
SUB CreateIni(filename as string)
print filename
OPENFILE inifile,filename,"W"
print WRITE(inifile,"[Heeeeers Booob]")
print WritePrivateProfileString("Here is Bob","Bob","Hello Bob",inifile)
print _GetLastError()
CLOSEFILE inifile
ENDSUB

CreateIni(GETSTARTPATH+"Table2-1.ini")
print:print "Press <Enter> to quit."
input ""
Title: Re: PrivateProfileString
Post by: Ionic Wind Support Team on June 16, 2008, 04:25:03 PM
You don't open a file for it.  The last parameter is the full path to the ini file.   

Just don't do it on Vista if your program exists in the program files directory, unless the .ini file is in the users documents path of course.

Paul.