Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reading INI using windows api
Message
De
10/11/2000 10:57:27
 
 
À
Tous
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Titre:
Reading INI using windows api
Divers
Thread ID:
00440229
Message ID:
00440229
Vues:
60
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform