VB6用API实现繁体简体转换

前端之家收集整理的这篇文章主要介绍了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,lngSrcLen
End If
ConvertChineseSimplifiedOrTraditional = strBuffer
End Function

猜你在找的VB相关文章