PDA

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


Cin0s3
Aug 15th, 2001, 09:26 PM
I am using GetPrivateProfileString to read an ini file, this works great on my Win2k machine but not my WinME system. Please help

VbAndersonic
Aug 16th, 2001, 08:16 PM
Hmm, you really need to paste the code you are using for this one. See if the code below works:

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
Private Sub Form_Load()
Dim Ret As String, NC As Long
WritePrivateProfileString App.Title, "KeyName", "This is the value", "c:\test.ini"
Ret = String(255, 0)
NC = GetPrivateProfileString(App.Title, "KeyName", "Default", Ret, 255, "C:\test.ini")
If NC <> 0 Then Ret = Left$(Ret, NC)
MsgBox Ret
Kill "c:\test.ini"
End Sub