当前位置: 代码迷 >> PB >> 获取窗口标题GetWindowText解决思路
  详细解决方案

获取窗口标题GetWindowText解决思路

热度:190   发布时间:2016-04-29 09:30:01.0
获取窗口标题GetWindowText
我在pb9.0里,使用GetWindowText,不知道为什么会出错?请用过这个函数的朋友指点。

声明部分:
Function long GetActiveWindow() LIBRARY "user32.dll" 
Function Long GetWindowText(Long hwnd,ref String caption,Long cd) LIBRARY "user32.dll"

使用部分:
long hWnd
hWnd = GetActiveWindow() //'得到活动窗口的句柄 

STRING ls_caption 

ls_caption = Space(255)

GetWindowText(hwnd,ls_caption,255)

但是在执行GetWindowText这个函数的时候,就出错了,不知道什么原因,请用过这个函数的朋友指点。

------解决方案--------------------

FUNCTION ulong GetWindowText(ulong hwnd,ref string lpString,ulong cch) LIBRARY "user32.dll" ALIAS FOR "GetWindowTextA"

这么声明就行了!
  相关解决方案