求助:VB调用SendMessage导致程序崩溃
我想用SendMessage跨进程获取文本框中的文字,之前我已经获得了正确的句柄。
源代码:
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongConst WM_GetText As Long = 13Public Function subSendMyMsg(lngHwnd As Long) As String On Error Resume Next1 Dim strWord As String2 strWord = String(255, Chr(0))3 Call SendMessage(lngHwnd, WM_GetText, 255, strWord)4 subSendMyMsg = Left(strWord, InStr(1, strWord, Chr(0)) - 1)End Function
Call SendMessage(lngHwnd, WM_GetText, 255, Byval strWord)
[解决办法]
http://bbs.bccn.net/thread-309935-1-9.html