修改QQ的程序
作者: 邵雪璇
下载本文示例源代码
最近一网友要戒QQ,要我写个程序帮他把QQ戒了,昨天一天搞定了,里面有点有用的东西拿出来 如果觉得我很菜不要骂我 :E
主要思路:
FindWindow -> "发送消息" "查看消息"
修改QQ的Button,Static,Edit控件
修改注册表,让其自动运行
具体代码如下:
char buttoncaption[4][20]={"聊天记录(&H)","对话模式(&T)","取消发送(&C)","送讯息(&S)"};HWND WndHandle;HWND WndEdit;HWND static_c[11];//static 的hwnd,因为很多不确定设了11个HWND button_c[6];//Button的Hwnd 查看消息4个发送消息6个 所以取6个WndHandle = ::FindWindow(NULL, "查看消息");::SetWindowText( WndHandle, "聊天真的很痛苦的呀");if( WndHandle != NULL){/////////开始搞定Edit////////////////////WndEdit = ::FindWindowEx( WndHandle,NULL,"Edit",""); 类名 Caption::EnableWindow( WndEdit, false );/////////Edit被搞定///////////////////////////////开始搞定Button//////////for( int i = 0; i < 4; i++ ){button_c[i] = FindWindowEx(WndHandle,NULL,"Button",buttoncaption[i]);}for( i = 0; i < 4; i++ ){::EnableWindow( button_c[i],false);}//////////Button±被搞定////////////////////开始搞定Static/////////////static_c[0] = NULL;int n=0;for( i = 1; i < 11; i++ ){static_c[i] = FindWindowEx( WndHandle,static_c[i-1],"Static",NULL);//发现第二个参数为NULL时,FindWindowEx会返回一样的值,所以以上次取的Hwnd为参数//可以获得所有Static的HWND}for( i = 1; i < 11; i++ ){char caption[100];::GetWindowText( static_c[i],caption,100);if( strcmp(caption,"QQ#:") != 0 &&strcmp(caption,"昵称:") != 0 &&strcmp(caption,"Email:") != 0 &&strcmp(caption,"按ctrl + 回车键发送消息") != 0 ){static_index[n++] = i;}//把不要修改的剔除掉}for( i = 1; i <= 4; i++ ){int index = static_index[i-1];if( index < 0 || index > 10)continue;int dlgindex = ::GetDlgCtrlID( static_c[index] );::SetDlgItemText( WndHandle,dlgindex,s[i-1]);}::InvalidateRect( WndHandle,NULL,false);for( i = 1; i <= 4; i++ ){::UpdateWindow( static_c[static_index[i-1]] );}//////////Static±?被搞定///////////////////}修改注册表如下:
char path[50];::GetCurrentDirectory(50,path);strcat(path,"\戒掉qq聊天的坏习惯.exe");LPBYTE path_set = pchar_To_LPBYTE( path );DWORD type = REG_SZ;DWORD cbdata = strlen(path)+1;HKEY hkey;LPCTSTR data_set = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run\";long ret_0 = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_set,0,KEY_ALL_ACCESS,&hkey);long ret_1 = ::RegSetValueEx( hkey,"BadQQ",0,type,path_set,cbdata );::RegCloseKey( hkey );LPBYTE CShitDlg::pchar_To_LPBYTE( char* str){LPBYTE lpb=new BYTE[strlen(str)+1];for(int i=0; i < strlen(str);i++)lpb[i]=str[i];lpb[strlen(str)]=0;return lpb;}(全文完)