Referring to my general thread here
http://www.access-programmers.co.uk/forums/showthread.php?t=164073
I hinted at a problem which I thought dealt with Access Generally. The problem seems to be my API call thus this new thread.
How to call this function for unicode and NOT ANSI
The only thing I can find in this forum is this http://www.access-programmers.co.uk/forums/showthread.php?t=33283&highlight=unicode+api
which may provide some method.
If I understand my issue properly VBA is converting my strings to ANSI which means that when it searches a text file in Unicode it finds nothing.
I have read the StrPtr() could also help here, pointing to the place where my string is kept instead of passing the string to the API Call.
Usually I am happy to read about this but this time I really need some spoonfeeding here on how to do this because it is beyond me.
Following my theory on StrPtr I thought the following would be the solution but if finds nothing.
http://www.access-programmers.co.uk/forums/showthread.php?t=164073
I hinted at a problem which I thought dealt with Access Generally. The problem seems to be my API call thus this new thread.
How to call this function for unicode and NOT ANSI
Code:
Public Declare Function GetPrivateProfileString _
Lib "kernel32" Alias "GetPrivateProfileStringW" _
(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
which may provide some method.
If I understand my issue properly VBA is converting my strings to ANSI which means that when it searches a text file in Unicode it finds nothing.
I have read the StrPtr() could also help here, pointing to the place where my string is kept instead of passing the string to the API Call.
Usually I am happy to read about this but this time I really need some spoonfeeding here on how to do this because it is beyond me.
Following my theory on StrPtr I thought the following would be the solution but if finds nothing.
Code:
Public Function ProfileGetItem(sSection As String, _
sKeyName As String, _
sDefValue As String, _
sInifile As String) As String
'retrieves a value from an ini file
'corresponding to the section and
'key name passed.
Dim dwSize As Long
Dim nBuffSize As Long
Dim buff As String
'Call the API with the parameters passed.
'nBuffSize is the length of the string
'in buff, including the terminating null.
'If a default value was passed, and the
'section or key name are not in the file,
'that value is returned. If no default
'value was passed (""), then dwSize
'will = 0 if not found.
'
'pad a string large enough to hold the data
buff = Space$(2048)
nBuffSize = Len(buff)
dwSize = GetPrivateProfileString(StrPtr(sSection), _
StrPtr(sKeyName), _
sDefValue, _
buff, _
nBuffSize, _
sInifile)
If dwSize > 0 Then
ProfileGetItem = Left$(buff, dwSize)
End If
End Function