获取窗口标题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"
这么声明就行了!