I need to be able to read in Chinese characters and display them on a form. I found a previous post that showed how to retrieve them from the INI file and I have used that code but have not had success in displaying the value. Not sure if it is an API problem or a display problem.
The code is as follows:
Public Declare Function GetPrivateProfileStringW Lib "kernel32" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As String, _
ByVal lpDefault As String, _
lpReturnedString As Any, _
ByVal nSize As Long, _
ByVal lpFileName As String) As Long
Dim buf() As Byte
ReDim buf(254)
Dim theSection As String
theSection = "TEXTNCAPTIONS"
Dim theSize As Long
theSize = 255
Dim theCaption As String
theCaption = "USER ID:"
ReturnVal = GetPrivateProfileStringW(StrConv(theSection, vbUnicode), _
StrConv(theCaption, vbUnicode), _
StrConv(" ", vbUnicode), _
buf(0), _
theSize, _
StrConv(INIFileName, vbUnicode))
If ReturnVal <> 0 Then
NewString = StrConv(StrConv(Left(buf, ReturnVal), vbFromUnicode, 2052), vbUnicode)
If NewString <> "***" Then
frmObj.Font.name = ChrW(&H5B8B) + ChrW(&H4F53)
frmObj.Charset = 134
frmObj.Caption = NewString
End If
End If
Originally, I just had NewString = Left(buf, ReturnVal) but that was making NewString = ???, so I found the StrConv way of doing it above and it no longer puts ??? in NewString.
Instead, NewString = "Óû§Éí·Ý£º"
But, it is supposed to = 用户身份:
Any thoughts on how to solve this would be greatly appreciated.
The code is as follows:
Public Declare Function GetPrivateProfileStringW Lib "kernel32" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As String, _
ByVal lpDefault As String, _
lpReturnedString As Any, _
ByVal nSize As Long, _
ByVal lpFileName As String) As Long
Dim buf() As Byte
ReDim buf(254)
Dim theSection As String
theSection = "TEXTNCAPTIONS"
Dim theSize As Long
theSize = 255
Dim theCaption As String
theCaption = "USER ID:"
ReturnVal = GetPrivateProfileStringW(StrConv(theSection, vbUnicode), _
StrConv(theCaption, vbUnicode), _
StrConv(" ", vbUnicode), _
buf(0), _
theSize, _
StrConv(INIFileName, vbUnicode))
If ReturnVal <> 0 Then
NewString = StrConv(StrConv(Left(buf, ReturnVal), vbFromUnicode, 2052), vbUnicode)
If NewString <> "***" Then
frmObj.Font.name = ChrW(&H5B8B) + ChrW(&H4F53)
frmObj.Charset = 134
frmObj.Caption = NewString
End If
End If
Originally, I just had NewString = Left(buf, ReturnVal) but that was making NewString = ???, so I found the StrConv way of doing it above and it no longer puts ??? in NewString.
Instead, NewString = "Óû§Éí·Ý£º"
But, it is supposed to = 用户身份:
Any thoughts on how to solve this would be greatly appreciated.