General information
Category:
Coding, syntax & commands
Title:
Reading INI using windows api
I am using the following to read an ini file:
Public Declare Function GetPrivateProfileString Lib "kernel32" _
Alias "GetPrivateProfileStringA" (ByVal lpApplicationName _
As String, ByVal lpKeyName As Any, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal nSize As Long, _
ByVal lpFileName As String) As Long
Public gstrKeyValue As String * 256
strFileName = "c:\test\test.ini"
strSectionName = "DataSource Info"
strKeyName = "DataSetInfoDir"
lonValueSize = GetPrivateProfileString(strSectionName,_
"DataSetInfoDir", "?!?", gstrKeyValue, 256, strFileName)
vsDir = Left$(gstrKeyValue, lonValueSize)
I have it working properly, the Key value (variable vsDir) is exactly what I expect it to be. The problem that I have is that I want the parameter ByVal lpKeyName As Any to be a variable. Every time I try to send the parameter as a variable (strKeyName) I get a type error. If I hard code lpKeyName it works just fine. What do I dim the variable as for type ANY? I tried a string and that doesn't work.
Also, because I am not actually opening the file for input do I need to worry about closing the ini?
Thanks,
Nichole Brelje
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only