嗨,我想访问 HWND 的菜单,但不知何故我无法让它工作。itemCount 始终为 -1 但我想我什至没有 hMenu ..
我的代码是
void bla(){
#if _WIN32
HWND hwnd;
HMENU hMenu;
MENUITEMINFO mmi;
mmi.cbSize = sizeof(MENUITEMINFO);
hwnd = GetForegroundWindow();
hMenu = GetMenu(hwnd);
int itemCount = GetMenuItemCount(hMenu);
std::cout << "item count: " << itemCount << std::endl;
GetMenuItemInfo(hMenu, 0, true, &mmi);
DWORD dw = GetLastError();
#endif
}
我究竟做错了什么?