我是杨幂高中同学:VB unicode和汉字转换

来源:百度文库 编辑:高考问答 时间:2024/04/29 06:26:25
VB里有没有unicode和汉字转换的函数?

有这样的一些函数:

StrConv 函数的语法为:StrConv(待转换字串, 转换格式)

其中转换格式在这里用到的是:

vbUnicode 将 Ansi 字串转换为 Unicode

vbFromUnicode 将 Unicode 字串转换为 Ansi

Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
'GetWindowTextA' 指明这是一个非 Unicode API

以下是修改后的 API 声明:

Declare Function GetWindowText Lib "user32" Alias "GetWindowTextW" (ByVal hwnd As Long, ByVal lpString As Long, ByVal cch As Long) As Long
'GetWindowTextW' 指明这是一个 Unicode API

由此可见,修改一个非 Unicode API 成为一个 Unicode API 的要点是:
* 把 Alias 里函数名的结尾 'A' 换成 'W'。
* 把所有 ByVal *** As String ,改为 ByVal *** As Long 。