Can antone give me some hint about saving and loading options to/from an ini file:confused:
Printable View
Can antone give me some hint about saving and loading options to/from an ini file:confused:
Search these forums. You'll find more code examples than you'll need.
it`s quite hard to find
VB Code:
'MODULE FOR RETRIEVING AND SAVING DATA TO/FROM INI DATA Option Explicit 'API WRITE TO INI FILE Declare Function WritePrivateProfileString _ Lib "kernel32" Alias "WritePrivateProfileStringA" _ (ByVal lpApplicationName As String, ByVal _ lpKeyName As Any, ByVal lsString As Any, _ ByVal lplFileName As String) As Long 'API READ FROM INI Declare Function GetPrivateProfileString _ Lib "kernel32" Alias "GetPrivateProfileStringA" _ (ByVal lpApplicationName As String, ByVal _ lpKeyName As String, ByVal lpDefault As String, _ ByVal lpReturnedString As String, ByVal nSize As Long, _ ByVal lpFileName As String) As Long Function GetINIString(AppName, KeyName, INIFILENAME) As String ' RETURNS A STRING FROM AN INI FILE On Error GoTo ErrGetINIString Dim ReturnedString As String Dim i, Size, Result As Integer Dim SharedExtensionsDir As String Dim SharedExtensionsServer As String ReturnedString = Space$(256) Size = Len(ReturnedString) Size = GetPrivateProfileString(AppName, KeyName, "", ReturnedString, Size, INIFILENAME) ReturnedString = Left$(ReturnedString, Size) If ReturnedString <> "" Then ' VALUE FOUND GetINIString = ReturnedString Exit Function End If Exit Function ErrGetINIString: MsgBox "Problem with accessing data in ini file.", vbOKOnly, "Internal Error Message" Exit Function End Function 'WRITES A STRING TO AN INI FILE Function WriteINI(strsection As String, strkey As String, strkeyvalue As String, strfullpath As String) Call WritePrivateProfileString(strsection$, UCase$(strkey$), strkeyvalue$, strfullpath$) End Function
James;
What are these 2 variables for?
Dim SharedExtensionsDir As String
Dim SharedExtensionsServer As String
Where are tese used at?
They're not, but you declare them.
Ill be damned, left overs from something in the past, I suppose...