Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reading an INI file
Message
 
To
12/02/1999 17:23:19
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00187229
Message ID:
00187371
Views:
23
>Any sample on reading an INI file?
>
>I would like to read some parameters that I created in a small INI file.

Give this sample a try:

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 Function ReadFromINI(ByVal pSection As String, _
ByVal pKey As String, _
ByVal pDefault As String, _
ByVal pPath As String _
) As String
Dim lngReturn As Long
Dim strReturn As String

strReturn = String$(200, 0)
lngReturn = GetPrivateProfileString(pSection, pKey, pDefault, strReturn, Len(strReturn), pPath)
ReadFromINI = Left$(strReturn, lngReturn)
End Function


You can call it this way:
MyVariable = ReadFromINI("ODBC", "DB-SERVER", "GAA-ERREUR", App.Path & "\GAA.INI")

You can also take a look at WritePrivateProfileString function that write to an INI file.
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform