注册 登录
编程论坛 VB6论坛

API函数获取记事本信息的问题

lhx1986 发布于 2013-09-08 19:47, 430 次点击
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) 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 Sub Command1_Click()
Dim a As Long
Dim b As Long
Dim d As Long
Dim c As String

a = FindWindow(vbNullString, "无标题 - 记事本")
d = FindWindowEx(a, 0, "Edit", vbNullString)
c = Space(255)
GetWindowText d, c, 255
Text1.Text = c
End Sub
为什么text1获取不了记事本的内容,记事本是打开着的。哪位老师能指教?
2 回复
#2
bczgvip2013-09-09 01:06

你打开的是现有的文件吧.【xxx.txt - 记事本】
直接用类名找不好过么
#3
lhx19862013-09-09 10:03
能找到记事本但就是获取不了其中的内容
1