PDA

Click to See Complete Forum and Search --> : GetPrivateProfileString


Jul 13th, 2000, 08:58 PM
I am attemting to use GetPrivateProfileString to read from an INI type file, but it keeps returning 0. WritePrivateProfileString and GetPrivateProfileInt work fine. here is my code:

rc = GetPrivateProfileString(appname, keyname, "", variable, 255, filename)

what am i doing wrong?

Jul 13th, 2000, 11:24 PM
Try using this code instead.


Public 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
Public 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

Public Function readini(strsection As String, strkey As String, strfullpath As String) As String
Dim strbuffer As String
Let strbuffer$ = String$(750, Chr$(0&))
Let readini$ = Left$(strbuffer$, GetPrivateProfileString(strsection$, ByVal LCase$(strkey$), "", strbuffer, Len(strbuffer), strfullpath$))
End Function

Public Sub writeini(strsection As String, strkey As String, strkeyvalue As String, strfullpath As String)
Call WritePrivateProfileString(strsection$, UCase$(strkey$), strkeyvalue$, strfullpath$)
End Sub


Hope that helps.