久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='2UVJH'></tfoot>
  • <i id='2UVJH'><tr id='2UVJH'><dt id='2UVJH'><q id='2UVJH'><span id='2UVJH'><b id='2UVJH'><form id='2UVJH'><ins id='2UVJH'></ins><ul id='2UVJH'></ul><sub id='2UVJH'></sub></form><legend id='2UVJH'></legend><bdo id='2UVJH'><pre id='2UVJH'><center id='2UVJH'></center></pre></bdo></b><th id='2UVJH'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='2UVJH'><tfoot id='2UVJH'></tfoot><dl id='2UVJH'><fieldset id='2UVJH'></fieldset></dl></div>

  • <legend id='2UVJH'><style id='2UVJH'><dir id='2UVJH'><q id='2UVJH'></q></dir></style></legend>

    <small id='2UVJH'></small><noframes id='2UVJH'>

      • <bdo id='2UVJH'></bdo><ul id='2UVJH'></ul>

        Win32 - 獲取應用程序的主 Wnd 句柄

        Win32 - Get Main Wnd Handle of application(Win32 - 獲取應用程序的主 Wnd 句柄)

          <tfoot id='eUy9v'></tfoot>

          <small id='eUy9v'></small><noframes id='eUy9v'>

            <tbody id='eUy9v'></tbody>
          1. <i id='eUy9v'><tr id='eUy9v'><dt id='eUy9v'><q id='eUy9v'><span id='eUy9v'><b id='eUy9v'><form id='eUy9v'><ins id='eUy9v'></ins><ul id='eUy9v'></ul><sub id='eUy9v'></sub></form><legend id='eUy9v'></legend><bdo id='eUy9v'><pre id='eUy9v'><center id='eUy9v'></center></pre></bdo></b><th id='eUy9v'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='eUy9v'><tfoot id='eUy9v'></tfoot><dl id='eUy9v'><fieldset id='eUy9v'></fieldset></dl></div>

            <legend id='eUy9v'><style id='eUy9v'><dir id='eUy9v'><q id='eUy9v'></q></dir></style></legend>

                • <bdo id='eUy9v'></bdo><ul id='eUy9v'></ul>
                • 本文介紹了Win32 - 獲取應用程序的主 Wnd 句柄的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我已將我的 dll 注入進程.如何獲取宿主應用程序的主窗口句柄?

                  I have injected my dll into process. How can I get Main window handle of host application?

                  推薦答案

                  宿主應用程序可能有多個主窗口".要檢測它們,您可以

                  The host application may have multiple 'main windows'. To detect them, you could

                  1. 調用 GetCurrentProcessId獲取當前進程的PID
                  2. 調用 EnumWindows遍歷桌面的所有頂級窗口
                  3. 對于桌面上的每個窗口,調用 GetWindowThreadProcessId獲取創建窗口的進程的PID
                  4. 如果窗口的 PID 與您自己進程的 PID 匹配,請記住該窗口.

                  這為您提供了由您注入 DLL 的進程創建的頂級窗口列表.但是,請注意,這種方法可能會產生在您處理構建的窗口列表時已被破壞的窗口.因此,在使用 Windows 執行某些操作時,請確保使用 IsWindow 函數以確保手頭的窗口仍然有效(這仍然容易出現競爭條件,因為在您調用 IsWindow 和實際訪問窗口,但時間窗口要小得多).

                  That gives you a list of toplevel windows created by the process which you injected your DLL into. However, please note that this approach may yield windows which have been destroyed by the time you process the constructed list of windows. Hence, when doing something with the windows, make sure to use the IsWindow function to ensure that the window at hand is still valid (this is still prone to race conditions since the window may become invalid between your call to IsWindow and actually accessing the window, but the time window is much smaller).

                  這是一個實現該算法的 C++ 函數.它實現了一個 getToplevelWindows 函數,該函數產生一個 std::vector,其中包含當前進程的所有頂級窗口的句柄.

                  Here's a C++ function implementing this algorithm. It implements a getToplevelWindows function which yields a std::vector<HWND> containing the handles of all toplevel windows of the current process.

                  struct EnumWindowsCallbackArgs {
                      EnumWindowsCallbackArgs( DWORD p ) : pid( p ) { }
                      const DWORD pid;
                      std::vector<HWND> handles;
                  };
                  
                  static BOOL CALLBACK EnumWindowsCallback( HWND hnd, LPARAM lParam )
                  {
                      EnumWindowsCallbackArgs *args = (EnumWindowsCallbackArgs *)lParam;
                  
                      DWORD windowPID;
                      (void)::GetWindowThreadProcessId( hnd, &windowPID );
                      if ( windowPID == args->pid ) {
                          args->handles.push_back( hnd );
                      }
                  
                      return TRUE;
                  }
                  
                  std::vector<HWND> getToplevelWindows()
                  {
                      EnumWindowsCallbackArgs args( ::GetCurrentProcessId() );
                      if ( ::EnumWindows( &EnumWindowsCallback, (LPARAM) &args ) == FALSE ) {
                        // XXX Log error here
                        return std::vector<HWND>();
                      }
                      return args.handles;
                  }
                  

                  更新:這些天(我給出答案大約四年后)我也會考慮 遍歷應用程序的線程列表,然后使用EnumThreadWindows 在每個線程上.我注意到這在許多情況下要快得多.

                  UPDATE: These days (about four years after I gave the answer) I would also consider traversing the list of threads of the application and then using EnumThreadWindows on each thread. I noticed that this is considerably faster in many cases.

                  這篇關于Win32 - 獲取應用程序的主 Wnd 句柄的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  In what ways do C++ exceptions slow down code when there are no exceptions thown?(當沒有異常時,C++ 異常會以何種方式減慢代碼速度?)
                  Why catch an exception as reference-to-const?(為什么要捕獲異常作為對 const 的引用?)
                  When and how should I use exception handling?(我應該何時以及如何使用異常處理?)
                  Scope of exception object in C++(C++中異常對象的范圍)
                  Catching exceptions from a constructor#39;s initializer list(從構造函數的初始化列表中捕獲異常)
                  Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 說明符 C++11 noexcept 之間的區別)
                    <tbody id='bxw6A'></tbody>
                • <small id='bxw6A'></small><noframes id='bxw6A'>

                    <tfoot id='bxw6A'></tfoot>

                    1. <i id='bxw6A'><tr id='bxw6A'><dt id='bxw6A'><q id='bxw6A'><span id='bxw6A'><b id='bxw6A'><form id='bxw6A'><ins id='bxw6A'></ins><ul id='bxw6A'></ul><sub id='bxw6A'></sub></form><legend id='bxw6A'></legend><bdo id='bxw6A'><pre id='bxw6A'><center id='bxw6A'></center></pre></bdo></b><th id='bxw6A'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='bxw6A'><tfoot id='bxw6A'></tfoot><dl id='bxw6A'><fieldset id='bxw6A'></fieldset></dl></div>
                          • <bdo id='bxw6A'></bdo><ul id='bxw6A'></ul>
                          • <legend id='bxw6A'><style id='bxw6A'><dir id='bxw6A'><q id='bxw6A'></q></dir></style></legend>
                            主站蜘蛛池模板: 亚洲三级av | 欧美激情国产日韩精品一区18 | 欧美综合一区二区 | 成人在线视频免费观看 | 久久黄色| wwww.xxxx免费| 欧美日韩国产在线 | 黄色成人av| 久久一 | 日本国产一区二区 | 成人在线视频观看 | 亚洲精品视频免费看 | 日韩欧美在线观看 | 综合一区二区三区 | 日日夜夜影院 | 色橹橹欧美在线观看视频高清 | 亚洲欧美在线观看视频 | 日韩欧美电影在线 | 午夜视频在线 | 久久综合久久久 | 精品久久国产视频 | 亚洲欧美日韩精品久久亚洲区 | 久久久久久国产精品免费免费 | 日韩一级一区 | 国产精品精品久久久 | 日韩欧美在线免费观看 | 国产午夜视频 | 国产精品欧美一区二区 | 欧美日韩黄色一级片 | 最近免费日本视频在线 | 成人av一区 | 日韩免费一区二区 | 狠狠操狠狠操 | 亚洲欧美日韩久久 | 一区二区日本 | 精品九九九 | 亚洲黄色一级 | av在线播放国产 | 欧美一级小视频 | 亚洲精品视频观看 | 99久久精品一区二区毛片吞精 |