winapi - "GetForegroundWindow: identifier not found" in visual studio 2015 -
i developing windows app in visual studio 2015 using c++. need getforegroundwindow() , getwindowtext() return app focusing on. however, says getforegroundwindow() , getwindowtext() undefined i've included "windows.h". tried go definition of getforegroundwindow(), led me "winuser.h", included "winuser.h" well. still not help. here code:
#include "mainpage.xaml.h" #include <windows.h> #include <winuser.h> #include <winapifamily.h> #include <string> #include <stdio.h> #include <iostream> using namespace app1; using namespace platform; using namespace windows::foundation; using namespace windows::foundation::collections; using namespace windows::ui::xaml; using namespace windows::ui::xaml::controls; using namespace windows::ui::xaml::controls::primitives; using namespace windows::ui::xaml::data; using namespace windows::ui::xaml::input; using namespace windows::ui::xaml::media; using namespace windows::ui::xaml::navigation; using std::cout; using std::endl; mainpage::mainpage() { initializecomponent(); } hwnd currenthwnd, hwnd = null; char wnd_title[1024]; void app1::mainpage::focus_app_click(platform::object^ sender, windows::ui::xaml::routedeventargs^ e) { currenthwnd = getforegroundwindow(); getwindowtext(hwnd, wnd_title, sizeof(wnd_title)); cout << wnd_title << endl; } any ideas? in advance!
getforegroundwindowand getwindowtext in winuser.h declared inside #if winapi_family_partition(winapi_partition_desktop) macro block. use them windows desktop applications.
Comments
Post a Comment