Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reading an INI file
Message
 
À
12/02/1999 17:23:19
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00187229
Message ID:
00187371
Vues:
24
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform