如何获得QQ程序主窗口的句柄和标题(就是QQ号)呢

wxuevb 2003-03-19 05:10:38
如何获得QQ程序主窗口的句柄和标题(就是QQ号)呢?请大家 帮助我,我的QQ是79110201,email是asdfg6917@sina.com
...全文
188 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wdir 2003-03-27
  • 打赏
  • 举报
回复
我使用了vc知识库上的一个类 CFindKillProcess (EnumProc.cpp),如果你想得到QQ上窗体等资源,可以使用VC以资源的方式打开QQ.exe
void CRecordVCDlg::OnButton2() //自动登陆QQ的方法
{
// TODO: Add your control notification handler code here
HWND hWnd=NULL,hWndChild=NULL,hTemp=NULL;
int childId;
long style=0l;
CFindKillProcess FindProc;
DWORD pid1=FindProc.FindProcess("QQ.exe",TRUE);
//hWnd=::FindWindow(NULL,"QQ用户登录");

BOOL bClassName=TRUE;// show window classname
BOOL bTitle=TRUE;// show window title
BOOL bBare=TRUE;
int count=0;
BOOL bFirstModule = TRUE;
CProcessIterator itp;
for (DWORD pid=itp.First(); pid; pid=itp.Next()) {
// Note: first module in CProcessModuleIterator is EXE for this process
//
TCHAR modname[_MAX_PATH];
CProcessModuleIterator itm(pid);
HMODULE hModule = itm.First(); // .EXE
if (hModule) {
GetModuleBaseName(itm.GetProcessHandle(),
hModule, modname, _MAX_PATH);

// Iterate over all top-level windows in process
//
BOOL bFirstWindow = TRUE;
CMainWindowIterator itw(pid);
for (HWND hwnd = itw.First(); hwnd; hwnd=itw.Next()) {
if (bFirstModule) {
if (!bBare) {

}
bFirstModule = FALSE;
}
if (bFirstWindow) {
char classname[256],title[256];
GetClassName(hwnd,classname,sizeof(classname));
::GetWindowText(hwnd,title,sizeof(title));
CString Caption;
Caption.GetBuffer(256);
Caption=modname;
Caption.ReleaseBuffer();
if (Caption.Find("QQ.exe",0)>=0)
{
hWnd=hwnd;
break;
}
bFirstWindow = FALSE;
} else {

}

}
bFirstWindow || count++;
}
}

CButton Btn;
CEdit Edit;
CComboBox CmbEdit;
HWND LoginHwnd=NULL,PassHwnd=NULL;
hTemp=NULL;



if (hWnd !=NULL)
{
do
{
hWndChild=::FindWindowEx(hWnd,hTemp,"BUTTON",NULL);

if (hWndChild !=NULL)
{
childId=::GetDlgCtrlID(hWndChild);
switch (childId)
{
case 138:
CmbEdit.Attach(hWndChild);
CmbEdit.SetWindowText(m_QQCount);
CmbEdit.UpdateData(TRUE);
CmbEdit.Detach();
break;
case 180:
Edit.Attach(hWndChild);
long cbstyle;
cbstyle=GetWindowLong(hWndChild,180);
cbstyle |= CBS_DROPDOWNLIST;
SetWindowLong(hWndChild,180,cbstyle);

Edit.SetWindowText(m_QQPassWord);
Edit.UpdateData(TRUE);
Edit.Detach();
PassHwnd=hWndChild;
break;
case 323:
Btn.Attach(hWndChild);
Btn.SetCheck(0);
Btn.Detach();
break;
case 324:
Btn.Attach(hWndChild);
Btn.SetCheck(1);
Btn.Detach();
break;
case 1:
LoginHwnd=hWndChild;
break;
case 2:
break;
default:
break;
}
}
hTemp=hWndChild;
}while (hWndChild!=NULL);
CWnd cwnd;
CWnd *Cb=NULL;
cwnd.Attach(hWnd);
Cb=cwnd.GetDlgItem(138);
Cb->SetWindowText(m_QQCount);
Cb=cwnd.GetDlgItem(180);
Cb->SetWindowText(m_QQPassWord);
cwnd.Detach();
WPARAM wParam;
LPARAM lParam;

wParam = BN_CLICKED << 16;
wParam += 1;

lParam = (LPARAM)LoginHwnd;
char lp0[256];
::GetWindowText(PassHwnd,lp0,256);

::SendMessage(hWnd, WM_COMMAND, wParam, lParam);
}

}

———————————
┏━★━━◆━━★━┓
♂欢|◢CSDN◣|使♂       
┃迎|◥论坛助手◤|用┃       
┗━☆━━◇━━━☆┛      
littleV 2003-03-19
  • 打赏
  • 举报
回复
spy++
:)
skyzxg 2003-03-19
  • 打赏
  • 举报
回复
图谋不轨哦:)
kreven 2003-03-19
  • 打赏
  • 举报
回复
你想盗QQ呀
anjy 2003-03-19
  • 打赏
  • 举报
回复
http://www.vckbase.com/document/viewdoc.asp?id=277

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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