1,485
社区成员
发帖
与我相关
我的任务
分享
Private Declare Function MessageBox Lib "user32" Alias "MessageBoxW" (ByVal hwnd As Long, _
ByRef lpText As Any, _
ByRef lpCaption As Any, _
ByVal wType As Long) As Long
Private Declare Function MultiByteToWideChar Lib "kernel32" (ByVal CodePage As Long, _
ByVal dwFlags As Long, _
ByVal lpMultiByteStr As String, _
ByVal cchMultiByte As Long, _
ByRef lpWideCharStr As Any, _
ByVal cchWideChar As Long) As Long
Private Const CP_ACP = 0 ' default to ANSI code page
Private Sub Command1_Click()
Dim str_message As String, _
str_title As String, _
array_message() As Byte, _
attay_title() As Byte
str_message = "这是 UNICODE 提示信息,请您确定。"
str_title = "UNICODE 标题"
array_message = ASCII2UNICODE(str_message)
attay_title = ASCII2UNICODE(str_title)
MessageBox 0, array_message(0), attay_title(0), 64
End Sub
Private Function ASCII2UNICODE(ByVal in_str_ascii As String) As Byte()
Dim wLength As Long, _
out_buff() As Byte
wLength = MultiByteToWideChar(CP_ACP, 0, in_str_ascii, -1, vbNull, 0) ' 取得要转换的宽字符空间大小
ReDim out_buff(wLength)
MultiByteToWideChar CP_ACP, 0, in_str_ascii, -1, out_buff(0), wLength
ASCII2UNICODE = out_buff
End Function