我妈妈上QQ总是不知道如何上,每次都打电话过来问,电话里也说不清楚,所以写了这个程序。
这个程序的移植性不怎么样,因为只是为了自己方便而做的,呵呵,所以就简单起见。
稍微改下,就是让MyCreateProcess的时候,检查是否成功,不成功说明路径不对,弹出一个对话框,来让用户指定路径。
主要代码如下:
struct LogIn
{
int index; //索引
char *QQUser; //QQ号码
char *QQPass; //QQ密码
char *QQName; //QQ昵称
};
void CMyToolDlg::InitUserInfo()
{
LogIn LI[3]=
{
0, "104817737", "123", "拾樓桦^@^oо",
1, "251105587", "123", "?(りベ動了",
2, "460809865", "123", "C++之旅"
};
CComboBox*pComb=(CComboBox*)GetDlgItem(IDC_CCOM_QQNO);
ASSERT(pComb);
pComb->DeleteString(0);
int num=sizeof(LI)/sizeof(LogIn);
for (int i=0;i<num;i++)
{
m_vecLi.push_back(LI);
pComb->AddString(LI.QQName);
}
}
BOOL CMyToolDlg::OnInitDialog()
{
......
// TODO: Add extra initialization here
InitUserInfo();
UpdateData(FALSE);
return TRUE;
}
void CMyToolDlg::MyCreateProcess()
{
//--Method one--//
STARTUPINFO si;
PROCESS_INFORMATION prcInfo;
memset(&prcInfo,sizeof(prcInfo),0);
memset(&si, sizeof(si),0);
si.cb = sizeof(si);
si.lpReserved = NULL;
si.lpDesktop = NULL;
si.lpTitle = NULL;
si.cbReserved2=0;
si.lpReserved2 = NULL;
si.dwFlags = STARTF_FORCEOFFFEEDBACK;
si.dwX = 100;
si.dwY = 100;
si.dwXSize = 320;
si.dwYSize = 240;
CreateProcess(m_szFile,NULL,NULL, NULL, NULL,0,NULL,NULL,&si,&prcInfo);
//--Method two--//
/* CString path="C:\\Program Files\\Tencent\\QQ\\";
ShellExecute(NULL,"open",_T("QQ.exe"), NULL,path,SW_SHOW);*/
}
void CMyToolDlg::InputQQNumber(CWnd *pWnd,LogIn li)
{
ASSERT(pWnd);
CComboBox *pCob = (CComboBox *)pWnd->GetDlgItem(138);
pCob->DeleteString(0);
int userLen=strlen(li.QQUser);
char cNo;
for(int i=0;i<userLen;i++)
{
cNo=li.QQUser;
pCob->SendMessage(WM_CHAR, (WPARAM)cNo, 0);
}
}
void CMyToolDlg::InputQQPassword(CWnd *pWnd,LogIn li)
{
ASSERT(pWnd);
CWnd *pNextWnd = pWnd->GetNextWindow(GW_CHILD);
pNextWnd = pNextWnd->GetNextWindow(GW_HWNDNEXT);
for(;pNextWnd!=NULL;pNextWnd=pNextWnd->GetNextWindow(GW_HWNDNEXT))
{
if (pNextWnd)
{
CEdit* pPwd=(CEdit*)pNextWnd->GetDlgItem(16038);
if (pPwd)
{
pPwd->SetSel(0, -1);
pPwd->Clear();
int passLen=strlen(li.QQPass);
char cKey;
for(int i=0;i<passLen;i++)
{
cKey=li.QQPass;
pPwd->SendMessage(WM_CHAR, (WPARAM)cKey,0);
}
break;
}
}
}
}
void CMyToolDlg::PushLogInButton(CWnd *pWnd,UINT ButtonID)
{
ASSERT(pWnd);
CButton *pBtnLogin = (CButton *)pWnd->GetDlgItem(ButtonID);
if (pBtnLogin)
{
pBtnLogin->PostMessage(WM_LBUTTONDOWN, 0, 0);
pBtnLogin->PostMessage(WM_LBUTTONUP, 0, 0);
}
}
void CMyToolDlg::OnQq()
{
ShowWindow(SW_HIDE);
&nb