vb用sendmessage发送中文
答案:3 悬赏:30 手机版
解决时间 2021-03-26 08:45
- 提问者网友:雪舞兮
- 2021-03-25 20:03
vb用sendmessage发送中文
最佳答案
- 五星知识达人网友:孤老序
- 2021-03-25 21:23
使用WM_SETTEXT 消息 WM_char 是单个字符
Public Const WM_SETTEXT = 12
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
窗体中
Dim i As Long
Dim s As String
s = "你要输入的文字"
i = SendMessage(hwnd, WM_SETTEXT, 0, ByVal s)
另 楼上两位说直接使用SetWindowText 这个函数如果是本地进程可以使用
如过是其他进程则只能使用SendMessage
这个是MSDN原话
If the target window is owned by the current process, SetWindowText causes a WM_SETTEXT message to be sent to the specified window or control. If the control is a list box control created with the WS_CAPTION style, however, SetWindowText sets the text for the control, not for the list box entries.
To set the text of a control in another process, send the WM_SETTEXT message directly instead of calling SetWindowText.
==============================================
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
我把声明写错了 拉了点东西 呵呵
Public Const WM_SETTEXT = 12
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
窗体中
Dim i As Long
Dim s As String
s = "你要输入的文字"
i = SendMessage(hwnd, WM_SETTEXT, 0, ByVal s)
另 楼上两位说直接使用SetWindowText 这个函数如果是本地进程可以使用
如过是其他进程则只能使用SendMessage
这个是MSDN原话
If the target window is owned by the current process, SetWindowText causes a WM_SETTEXT message to be sent to the specified window or control. If the control is a list box control created with the WS_CAPTION style, however, SetWindowText sets the text for the control, not for the list box entries.
To set the text of a control in another process, send the WM_SETTEXT message directly instead of calling SetWindowText.
==============================================
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
我把声明写错了 拉了点东西 呵呵
全部回答
- 1楼网友:鱼芗
- 2021-03-25 23:37
顶楼上,建议用SetWindowText API函数
- 2楼网友:鱼忧
- 2021-03-25 23:01
你要发送的目标是一个文本框么?是的话就用SETTEXT,wParam填0,lParam填你那个中文串的变量。
如果目标不是文本框,可能就要找其他的消息了。
另外,这类操作有的可以不用SendMessage的,比如SetWindowText API封装了一种发送SETTEXT message的情况。
如果目标不是文本框,可能就要找其他的消息了。
另外,这类操作有的可以不用SendMessage的,比如SetWindowText API封装了一种发送SETTEXT message的情况。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯