[code]
Declare Function FindWindowExW Lib “User32” (hwndParent As Integer, hwndChildAfter As Integer, lpszClass As Integer, lpszWindow As WString) As Integer
dim n as integer = &hC017
Dim handle As Integer
handle = FindWindowExW(0, 0, n, “”)[/code]
[quote=395700:@Andrew Lambert]An empty WString is not equal to a null pointer; pass a literal Nil as the last parameter:
handle = FindWindowExW(0, 0, n, Nil)[/quote]
@Andrew Lambert this little bit of information has opened up a lot for me. I never realized why I couldn’t get some declares working like I wanted. For instance:
Soft Declare Function FindWindowExW Lib "User32" (hwndParent As Integer, hwndChildAfter As Integer, lpszClass As WString, lpszWindow As WString) As Integer
By making the params for lpszClass and lpszWindow Variants and passing Nil I can finally loop through all the window handles manually like this:
while (ct < intMax)
currChild = FindWindowEx(GetDesktopWindow, prevChild, Nil, Nil)
if (currChild = -1) then
exit
else
inthWndCList.Append(currChild)
prevChild = currChild
ct = ct + 1
end
wend