vb用SETTEXT改变TEdit编辑框内容 - 爱问答

(爱问答)

vb用SETTEXT改变TEdit编辑框内容

句柄已经找到了,但编辑框没有一点反应
代码:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
'Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SetActiveWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Const BN_CLICKED = 0
Private Const BM_CLICK = &HF5
Private Const WM_SETTEXT = 12
Private Const WM_GETTEXT = &HD&
Private Const WM_KEYDOWN = &H100
 
Private Sub Command1_Click()
Dim hwnd As Long, hc As Long, hcc As Long, hccc As Long, hc4 As Long, hc5 As Long, hw As Long
Dim sBuffer As String
hwnd = FindWindow(vbNullString, "安装 - EQK 版本 1.0")
'MsgBox hwnd
'hwnd = FindWindow(vbNullString, "1.txt - 记事本")
hc = FindWindowEx(hwnd, 0, "TNewNotebook", vbNullString)
 
'MsgBox hc
hcc = FindWindowEx(hc, 0, "TNewNotebookPage", vbNullString)
'MsgBox hcc
hccc = FindWindowEx(hcc, 0, "TNewNotebook", vbNullString)
'MsgBox hccc
hc4 = FindWindowEx(hccc, 0, "TNewNotebookPage", vbNullString)
hc5 = FindWindowEx(hc4, 0, "TEdit", vbNullString)
hw = SendMessage(hc5, WM_SETTEXT, 0, App.Path & "EQK")
'MsgBox hc5
'sBuffer = Space(255)
'Call SendMessage(hc, WM_GETTEXT, 255, ByVal sBuffer)
'sBuffer = Left(sBuffer, InStr(sBuffer, Chr(0)) - 1)
'MsgBox sBuffer
 
End Sub

没有你的环境。无法真实帮你测试,但有2个问题

1、首先,你要保证所有的handle不能为0

在win10环境下,记事本的Edit框的类不再是TEdit.它就是Edit

你可以用spyxx看下程序得到的句柄与实际的是否一致

2.WM_SETTEXT必须是值,你的

hw = SendMessage(hc5, WM_SETTEXT, 0, App.Path & "EQK")

结果肯定不对。它传的是地址

要用

hw = SendMessage(hc5, WM_SETTEXT, 0, ByVal App.Path & "EQK")

下一篇:我电脑配置能玩武装突袭3吗?

上一篇:java版地图导入网易我的世界

热门标签:
excel 网盘 破解 word dll
最新更新:
微软重新评估新的Outlook的使用时机 联想推出搭载联发科Helio G80芯片组的Tab M9平板 英特尔创新大赛时间确定! 微软Edge浏览器在稳定渠道中推出Workspaces功能 英伟达RTX4060TiGPU推出MaxSun动漫主题! 谷歌地图为用户提供了街景服务! GameSir 在T4 Kaleid中推出了一款出色的控制器! 微软开始在Windows 11 中测试其画图应用程序的新深色模式! LG电子推出全球首款无线OLED电视 英伟达人工智能芯片崭露头角! Steam Deck可以玩什么游戏-Steam Deck价格限时优惠 雷蛇推出CobraPro鼠标 Kindle电子阅读器可以访问谷歌商店吗 Windows10如何加入组策略 window10图片查看器怎么没有了?