Public Class Form1
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Const WM_CHAR as Integer= &H102
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str As String = "hello !中华人民共和国"
Dim bytes() As Byte = System.Text.Encoding.Default.GetBytes(str)
For Each b As Byte In bytes
PostMessage(Me.TextBox1.Handle, WM_CHAR, b, 0)
Next
End Sub
End Class
上面API声明中的LONG需要全部改为Integer
WM_CHAR是可以输入中文的。