最近在写API Hook,已经钩取了关闭窗口时所调用的DestroyWindow系统调用。系统调用DestroyWindow时会传入当前待关闭窗口的句柄,所以我想根据该句柄获取其打开的文件句柄,但不知怎么写,求大神指点,感激不尽!!

解决方案 »

  1.   

    FindWindow
    The FindWindow function retrieves a handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows. This function does not perform a case-sensitive search. To search child windows, beginning with a specified child window, use the FindWindowEx function. HWND FindWindow(
      LPCTSTR lpClassName,  // class name
      LPCTSTR lpWindowName  // window name
    );
    Parameters
      

  2.   

    可能之前我说得不够清楚,现在再补充一点:我已经获取到了HWND类型的窗口句柄,而对于记事本来说,一个窗口打开的是一个txt文件,所以我想根据这个窗口句柄来获取所打开文件的句柄(类型为HANDLE)。
    很急!求指点啊!成功之后有加分!