vb 这个api函数怎么写!![取文本文档的窗口标题]

GetWindowTextVB声明DeclareFunctionGetWindowTextLib"user32"Alias"GetWindowTextA"(ByValhw... GetWindowTextVB声明Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long说明取得一个窗体的标题(caption)文字,或者一个控件的内容(在vb里使用:使用vb窗体或控件的caption或text属性)返回值Long,复制到lpString的字串长度;不包括空中止字符。会设置GetLastError参数表参数类型及说明hwndLong,欲获取文字的那个窗口的句柄lpStringString,预定义的一个缓冲区,至少有cch+1个字符大小;随同窗口文字载入cchLong,lpString缓冲区的长度注解不能用它从另一个应用程序的编辑控件中获取文字Top取文本文档的标题!到text! 展开
 我来答
百度网友4684e1e
2011-08-15 · TA获得超过2309个赞
知道小有建树答主
回答量:1266
采纳率:0%
帮助的人:549万
展开全部
换个别的API

Private Declare Function WindowFromPoint Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Integer, ByVal yPoint As Integer) As IntPtr
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As IntPtr) As Integer
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As IntPtr, ByVal lpString As String, ByVal cch As Integer) As Integer

Private Structure TitleEXD
<VBFixedString(255)> Public Text As String
End Structure

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As Integer = MousePosition.X, y As Integer = MousePosition.Y, res As String
Label1.Text = "鼠标当前坐标:" & x & "," & y
Dim hwnd As IntPtr = WindowFromPoint(x, y)
Label2.Text = "句柄:" & hwnd.ToString()
Dim Tlong As Integer = GetWindowTextLength(hwnd) Mod 65536 + 1
Dim TitleE As TitleEXD
TitleE.Text = Space(255)
Dim dlld As Integer = GetWindowText(Me.Handle, TitleE.Text, Tlong) Mod 65536
Label3.Text = "窗口标题:" & TitleE.Text
If dlld = 0 Then
res = "失败"
Else
res = "成功"
End If
Label4.Text = "获取标题" & res
End Sub
匿名用户
2011-08-16
展开全部
先声明用到的api函数:
用findwindow函数,以notepad类来查找窗口句柄 这里用tmphwnd表示
其次要声明字符串变量lpstring如
dim tmpstr as string*20
函数调用时
getwindowtext tmphwnd,tmpstr,20+1
print left(tmpstr,len(tmphwnd))
如果不错,打印的应该就是文本文档标题了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式