Ok i need some help trying to store some information for a "save game" but I Dont know how to write to a .ini or cfg file
Can you show me how to write and read a ini or cfg file
and can you also show me how to assign a keyboard Key such as A to do a certain function like attack or something
'profile (INI file) subs & functions
Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long '_32_BIT_CONVERTED_'
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long '_32_BIT_CONVERTED_'
Declare Function GetPrivateProfileSection Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Long, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long '_32_BIT_CONVERTED_'
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Long '_32_BIT_CONVERTED_'
Declare Function ErasePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As Long, ByVal lpFileName As String) As Long '_32_BIT_CONVERTED_'
Declare Function ErasePrivateProfileSection Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Long, ByVal lpString As Long, ByVal lpFileName As String) As Long '_32_BIT_CONVERTED_'
You can use those API functions to read from and write to ini files. By default it reads to and writes from the registry but you can use it to map to your own ini file. I can't remember off the top of my head how to do it, though. Sorry, it's been a while!
=--=--=--=--=--=--=--=--=--=--=--=--=--=
Please rate this post to show your appreciation for those that helped you.
What always inrigued me: does anybody know how these functions work, with respect to the .ini file?
I mean that:
If I write a new key to a section of an existing file, is the file completely rewritten then? Must-of somehow, I think, because it's a sequential text file.
And if I read entries from the file I might read them in any unpredictable order, so: is the file then scanned (opened read and closed) for any entry I read?
Sorry. Just curiousity.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.