首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > PB >

获取窗口标题GetWindowText解决思路

2012-03-29 
获取窗口标题GetWindowText我在pb9.0里,使用GetWindowText,不知道为什么会出错?请用过这个函数的朋友指点。

获取窗口标题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"

这么声明就行了!

热点排行