本文主要是介绍VB6用API实现繁体简体转换,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
由于正好需要一个繁体转简体的事情,弄这个函数将就用一下了。Private Declare Function LCMapString Lib "kernel32" Alias "LCMapStringA" ( _
ByVal Locale As Long, _
ByVal dwMapFlags As Long, _
ByVal lpSrcStr As String, _
ByVal cchSrc As Long, _
ByVal lpDestStr As String, _
ByVal cchDest As Long) As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long
Function ConvertChineseSimplifiedOrTraditional(ByVal strSrc As String, ByVal bSimplified As Boolean) As String
Dim lngSrcLen As Long
Dim strBuffer As String
lngSrcLen = lstrlen(strSrc)
If lngSrcLen = 0 Then Exit Function
strBuffer = Space(lngSrcLen)
If bSimplified Then '转换为简体
LCMapString &H804, &H2000000, strSrc, lngSrcLen, strBuffer, lngSrcLen
Else
LCMapString &H804, &H4000000, strSrc, lngSrcLen, strBuffer, lngSrcLen
End If
ConvertChineseSimplifiedOrTraditional = strBuffer
End Function
这篇关于VB6用API实现繁体简体转换的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!