作为一名前锋,我对 Windows API 非常缺乏经验。我正在尝试了解有关不同窗口的信息,所以我在ATOM
来自 Windows,我正在尝试调用GetClassInfo
,但是每次我调用它时它都会失败。我正在尝试看一个Untitled - Notepad
我在侧面打开了窗户。这是我正在使用的代码,我不确定从我并不真正拥有的 ATOM 调用 GetClassInfo 是否不正确,或者是否发生了其他情况。我只是想读出有关窗口属性的信息。这是我现在的代码:
#include <iostream>
#include <string>
#include <Windows.h>
int main(int argc, _TCHAR* argv[])
{
char* window_name = "Untitled - Notepad";
unsigned int window_name_length = strlen(window_name) + 1;
wchar_t* transformed_window_name = new wchar_t[window_name_length];
unsigned int number_of_characters_transformed;
mbstowcs_s(&number_of_characters_transformed, transformed_window_name, window_name_length, window_name, window_name_length);
HWND handle_to_window = FindWindow(NULL, transformed_window_name);
WINDOWINFO window_info;
if (!GetWindowInfo(handle_to_window, &window_info))
{
std::cout << "GetWindowInfo failed with error: " << GetLastError() << std::endl;
system("PAUSE");
exit(1);
}
LPTSTR my_atom_lptstr = MAKEINTATOM(window_info.atomWindowType);
HINSTANCE hinstance_to_window = (HINSTANCE)GetWindowLong(handle_to_window, GWL_HINSTANCE);
WNDCLASS my_wnd_class;
if (!GetClassInfo(hinstance_to_window, my_atom_lptstr, &my_wnd_class))
{
std::cout << "GetClassInfo failed with error: " << GetLastError() << std::endl;
system("PAUSE");
exit(1);
}
/* learn info from my_wnd_class */
return 0;
}
我收到错误 1411,即 ERROR_CLASS_DOES_NOT_EXIST,但我不太确定原因。
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)