|
Michael, As an added bonus I’ve also showed how to write a string to
an ini file. Regards GeoConsult I/S +++++++++++++++++++++++++++++++++++++++++++++++++++++ Declare sub
WritePrivateProfileString32 Lib
"KERNEL32" Alias "WritePrivateProfileStringA" (ByVal
lpszSection As String, ByVal
lpszEntry As String, ByVal
lpszString As String, ByVal
lplFileName As String) Declare Function
GetPrivateProfileString32 Lib
"kernel32" alias "GetPrivateProfileStringA" (ByVal
lpApplicationName As String, ByVal
lpKeyName As String, ByVal
lpDefault As String,
lpReturnedString As String, ByVal nSize
As Integer, ByVal
lpFileName As String) As Integer Declare Function
GetIni (ByVal IniFile
as string, ByVal Section
As String, ByVal key As
String, ByVal default
As String) As String Function GetIni (ByVal IniFile
as string, ByVal Section
As String, ByVal key As
String, ByVal
default As String) As String
Dim sRetVal,
sTmp As
String
Dim nWorked As
Integer
sRetVal =
string$(1000,"
")
nWorked =
GetPrivateProfileString32( Section, Key,
default, sRetVal, Len(sRetVal), IniFile) sRetVal =
rtrim$(ltrim$(left$(sRetVal,
nWorked)))
GetIni =
sRetval
End
Function
Declare Sub Sub Dim sW, sX, sY
, sF as string ' I assume, that
the ini files resides in the ' same directory
as the mbx. sF =
applicationdirectory$()+"myapp.ini" sW =
GetIni(sF,"GENERAL","Workfolder","") sX =
GetIni(sF,"GENERAL","X","") sY =
GetIni(sF,"GENERAL","Y","") Note sW +
" " + sX + " " + sY ' How to write
data to an ini file. Call
WritePrivateProfileString32
("GENERAL","NewValue","HURRAY", sF) Note
GetIni(sF,"GENERAL","NewValue","") End Sub +++++++++++++++++++++++++++++++++++++++++++++++++++++ Fra:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] På vegne af [EMAIL PROTECTED] Hi, Does anyone have a nice
clear example of how to read a key from an INI file? I have an application
e.g. “d:\apps\myapp.mb”
for which I have created “d:\apps\myapp.ini”
which looks like this: [GENERAL] Workfolder=c:\temp X=longitude Y=latitude How would I read the
value of each of the keys into separate string variables in myapp.mb? Regards Michael. Michael Zatorsky Interfaces,
Integration & Info Analysis Team QPRIME Project,
Operational Policing Program p. +61 7 3015
5566
|
_______________________________________________ MapInfo-L mailing list [email protected] http://www.directionsmag.com/mailman/listinfo/mapinfo-l
