windows 打印活动窗口类名和标题

2022-02-09  本文已影响0人  听取哇声一片_11c4

BOOL CALLBACK EnumChildProc(HWND hwnd,_In_ LPARAM lParam){

char szTitle[MAX_PATH]= {0};

char szClass[MAX_PATH]= {0};

int nMaxCount = MAX_PATH;

LPSTR lpclassName = szClass;

LPSTR lpwindowName = szTitle;

GetWindowTextA(hwnd,lpwindowName,nMaxCount);

GetClassNameA( hwnd,lpclassName,nMaxCount);

cout <<"[child window] window handle: " << hwnd << " window name: "

<<lpwindowName << " class name " <<lpclassName << endl;

return TRUE;

}

BOOL CALLBACK EnumlindowsProc(HWND hwnd,LPARAM lParam){

char szTitle[MAX_PATH] ={0};

char szClass[MAX_PATH] = {0};

int nMaxCount = MAX_PATH;

LPSTR lpClassName = szClass;

LPSTR lpwindowName = szTitle;

GetWindowTextA(hwnd,lpwindowName,nMaxCount);

GetClassNameA(hwnd,lpClassName,nMaxCount);

if(strcmp(lpClassName,"IME")!=0){

    cout <<"[Parent window] window handle: " << hwnd <<lpwindowName<<  " class name " << lpClassName << endl;

//EnumChildProc(hwnd,0);

}

if(strcmp(lpClassName,"TXGuiFoundation")==0){

    //  ::ShowWindow(hwnd,SW_SHOWNORMAL);

  // ::SetForegroundWindow(hwnd);

}

return TRUE;

}

int main(int argc, char *argv[])

{

  //  SetUnhandledExceptionFilter(callback);

    SingleApplication a(argc, argv);

    if(a.isRunning()){

        return 0;

    }

  EnumWindows(&EnumlindowsProc,0);

}

上一篇 下一篇

猜你喜欢

热点阅读