Hey Fellas,
I have a nice set of code snip's for VB6, but I recently upgraded to Visual Studio 2005, and its throwing me off something chronic.
I used to get/put to .ini using the following code:
Declarations:CODE
Private 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
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Procedure to get would be the very common:
CODE
Function GetFromINI(sSection As String, sKey As String, sDefault As String, sIniFile As String)
Dim sBuffer As String, lRet As Long
' Fill String with 255 spaces
sBuffer = String$(255, 0)
' Call DLL
lRet = GetPrivateProfileString(sSection, sKey, "", sBuffer, Len(sBuffer), sIniFile)
If lRet = 0 Then
' DLL failed, save default
If sDefault <> "" Then AddToINI sSection, sKey, sDefault, sIniFile
GetFromINI = sDefault
Else
' DLL successful
' return string
GetFromINI = Left(sBuffer, InStr(sBuffer, Chr(0)) - 1)
End If
End Function
And to put, the good ol':
CODE
Function AddToINI(sSection As String, sKey As String, sValue As String, sIniFile As String) As Boolean
Dim lRet As Long
' Call DLL
lRet = WritePrivateProfileString(sSection, sKey, sValue, sIniFile)
AddToINI = (lRet)
End Function
Of course, with the new structure in '05 the above doesn't work. Its whinges about the 'Any' file type in the declarations, and it doesn't like using the String$(#,#) function and I haven't found a suitable replacement for that either.
Do I honestly need to copy paste all the above stuff freely available on the net to prove I'm not doing "homework"?

Thanks in advance guys.
Tommy.