Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reading INI using windows api
Message
From
10/11/2000 10:57:27
 
 
To
All
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Title:
Reading INI using windows api
Miscellaneous
Thread ID:
00440229
Message ID:
00440229
Views:
58
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
Map
View

Click here to load this message in the networking platform