关于::FindWindow
我打开了windows自己带的计算器,然后用spy++取得类名和窗口名
hwnd=::FindWindow( "SciCalc ", "计算器 ");为什么得不到正确的句柄?
我是在2003下运行的
[解决办法]
Syntax
HWND FindWindow( LPCTSTR lpClassName,
LPCTSTR lpWindowName
);
Parameters
lpClassName
[in] Pointer to a null-terminated string that specifies the class name or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be in the low-order word of lpClassName; the high-order word must be zero.
If lpClassName points to a string, it specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx, or any of the predefined control-class names.
If lpClassName is NULL, it finds any window whose title matches the lpWindowName parameter.
lpWindowName
[in] Pointer to a null-terminated string that specifies the window name (the window 's title). If this parameter is NULL, all window names match.
// /////////////////////////
你可以直接这样:
hwnd=::FindWindow(NULL, "计算器 ");
if(hwnd == NULL)
{
TRACE( "Error: %d\n ", GetLastError());
}
[解决办法]
等运行了这个语句hwnd=::FindWindow( "SciCalc ", "计算器 ");后
你在看看hwnd的值是否有。
这个语句运行前如果你没有对hwnd赋初值智能感知就会显示hwnd 0xccccccc