
API GetPrivateProfileString and WritePrivateProfileString don't work.
This code example doesn't works. It seems to me that the recognizing of the
string at buffer level fails. Does anyone know why?
'---------------------------------------------------------------------
Public Const INI_FILE_NAME = "D:\Andrea\Axia\Dde\DDEClient.ini"
Public Const ABSENT = "Absent"
Public g_sDSNConnection As String
Public 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
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
Sub Main()
Dim lResult As Long
lResult = WritePrivateProfileString("Database", "DSN",
"ConnectionString",
NOME_INI_FILE)
g_sDSNConnection = String$(255, Chr(0))
lResult = GetPrivateProfileString("Database", "DSN", ABSENTE,
g_sDSNConnection, Len(g_sDSNConnection) + 1, INI_FILE_NAME)
MsgBox g_sDSNConnection
End Sub