visual studio 2015 - VS2015 C++ CLR Project GetForegroundWindow() Not Starting up -
i trying code program see current application open , base on application something. create empty clr project using vs 2015 c++. there @ moment have textbox , button start. have below code in myform.h file below code vs generates form, textbox , button:
private: void getapps() { hwnd hcurrentwindow = null; char title[256]; string stitle; while (true) { if (hcurrentwindow != getforegroundwindow()) { hcurrentwindow = getforegroundwindow(); getwindowtexta(hcurrentwindow, title, sizeof(title)); stitle = title; if (stitle.find("notepad++") != string::npos) { //npos returned find if substring wasn't found txtbox->text += "\r\n" + "notepad++"; } if (stitle.find("skype") != string::npos) { txtbox->text += "\r\n" + "skype"; } else { txtbox->text += "\r\n" + "non classified application."; } } } }
the code works in console application changing txtbox cout.
when run application compile , run when gets if (hcurrentwindow != getforegroundwindow()) { nothing. when debug it telling me wuser32.pdb not loaded suggesting load microsoft symbol servers, did did not help.
any clues why work in console not in forms? , possible fix?
Comments
Post a Comment