原代码如下:
Public Class Form1
Dim quit As Boolean = False
Dim tt As Integer = 0
Dim ip() As System.Net.IPAddress = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName)
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
';定时器事件!
Try
If tt > 0 Then
tt -= 1
Label1.Text = "定时关机正在执行,倒计时:" & tt \ 3600 & "时" & tt \ 60 Mod 60 & "分" & tt Mod 60 & "秒"
If tt = 1 Then
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\mwyclose.exe") ';关机
End
End If
Else
If My.Computer.Network.Ping(TextBox1.Text, 1000) = False Then
If quit Then
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\mwyclose.exe")
End
End If
quit = True
Timer1.Interval = 15000
MessageBox.Show(vbCrLf & "你掉线啦,15秒后重试!注意,如果再连接失败则直接关机!", "→无条件为你⊙制作!", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
Else
Timer1.Interval = 3000
quit = False
End If
End If
Catch ex As Exception
';如果网卡突然坏了,或者网线被拔出,则直接做关机处理!
If IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\mwyclose.exe") Then Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\mwyclose.exe")
End
End Try
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Me.Hide()
If e.CloseReason = CloseReason.TaskManagerClosing Then
MessageBox.Show(vbCrLf & "搞什么?竟然把任务管理器都打开啦!想结束我的进程啊?真晕!", "→无条件为你⊙幸灾乐祸的说:", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf e.CloseReason = CloseReason.WindowsShutDown And tt <> 1 Then
MessageBox.Show(vbCrLf & "你太愚蠢了,为了关掉我,竟然直接关机了!!!", "→无条件为你⊙大笑:", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf e.CloseReason = CloseReason.UserClosing Then
e.Cancel = True
MessageBox.Show(vbCrLf & "干什么干什么?想用Alt+F4关闭我?找死啊你!小心格式化你的硬盘!", "→无条件为你⊙愤怒的对你说:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
MessageBox.Show(vbCrLf & "其实想关我非常容易,按ESC键就可以啦,没有必要这么麻烦!", "→无条件为你⊙十分友好的说:", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Me.Show()
End Sub
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
If e.KeyChar Like "#" Or e.KeyChar = "." Or e.KeyChar = ControlChars.Back Then
Else
e.Handled = True
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
';载入窗体之前,最先执行的代码:
Try
Me.Text = "欢迎你!" & Environment.UserName & ",您的IP:" & ip(0).ToString
Me.AcceptButton = Button1 ';当按Enter键时激活的按扭。
Me.CancelButton = Button2 ';当按ESC键时激活的按扭。
Me.StartPosition = FormStartPosition.CenterScreen ';启动时在屏幕中央显示窗体
Me.TopMost = True ';顶层窗口,窗口永远在最前。
Me.KeyPreview = True ';注册键盘事件
Me.ShowInTaskbar = False ';在任务栏处不显示窗体
Me.ControlBox = False ';禁止最大化、最小化、关闭按扭。
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle ';禁止改变窗口大小。
Me.ForeColor = Color.Green
Me.BackColor = Color.Red
Label1.ForeColor = Color.Blue
Label1.Font = New Font("宋体", 11)
Label1.Text = "提供网络服务的主机IP:"
NotifyIcon1.ContextMenuStrip = ContextMenuStrip2
Dim j As Integer = 0
Dim m() As Char = ip(0).ToString.ToCharArray ';ip(0).ToString即为本机IP,此操作是将字符串分离成单个字符,为后面的判断做准备。
For i As Integer = 0 To ip(0).ToString.ToCharArray.Length - 1
If m(i) = "." Then
j += 1
End If
If j < 3 Then TextBox1.Text &= m(i)
Next
TextBox1.Text &= ".1" ';至此,成功算出默认服务器IP。
Dim y() As Byte = My.Resources.close ';创建一个读取资源文件的对象。
Dim f As New IO.FileStream(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\mwyclose.exe", IO.FileMode.Create)
f.Write(y, 0, y.Length)
f.Close() ';至此,EXE文件已经释放到程序文件夹中!
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
If IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\mwyclose.exe") Then IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\mwyclose.exe")
End
End Try
End Sub
Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
MessageBox.Show(vbCrLf & "本程序由QQ335342设计制作,欢迎您的使用!", "→无条件⊙欢迎您!", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Show()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Try
If ComboBox1.Text.Length = 0 Then ComboBox1.Text = "0"
If ComboBox1.Text.Contains(".") Or TextBox2.Text.Contains(".") Then
ComboBox1.Text = "0"
TextBox2.Text = "0"
MessageBox.Show(vbCrLf & "时间必须为数字,发现你输入了圆点,这是不允许的!", "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
If ComboBox1.Text = "0" And TextBox2.Text = "0" Then
MessageBox.Show(vbCrLf & "定时关机,在设置时间的时候最少要设置1分钟!", "→无条件⊙提示:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
Me.Hide()
NotifyIcon1.Visible = True
Timer1.Enabled = True
Button1.Visible = False
Button3.Visible = False
ComboBox1.Enabled = False
TextBox2.Enabled = False
TextBox1.Visible = False
tt = ComboBox1.Text * 3600 + TextBox2.Text * 60
Timer1.Interval = 1000
End If
End If
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
NotifyIcon1.Visible = False
If IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\mwyclose.exe") Then IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\mwyclose.exe")
End ';单击此按扭直接终止程序。
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
If My.Computer.Network.IsAvailable = False Then
MessageBox.Show(vbCrLf & "您的计算机没有接入Internet,或者没有活动网卡,程序终止!", "→无条件为你⊙程序设计", MessageBoxButtons.OK, MessageBoxIcon.Error)
NotifyIcon1.Visible = False
If IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\mwyclose.exe") Then IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\mwyclose.exe")
End
End If
If TextBox1.Text.Length < 9 Then
MessageBox.Show(vbCrLf & "严重错误,需要Pint的主机IP不合法。如果没有服务器,你也可以填写路由器IP,请重试!", "→无条件为你⊙制作,联系QQ:335342", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
MessageBox.Show(vbCrLf & "程序已经执行,将以托盘方式显示在任务栏的通知区域!", "→无条件为你⊙制作,联系QQ:335342", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
NotifyIcon1.Visible = True
Timer1.Enabled = True
If Me.Visible Then Me.Hide()
End If
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
Try
If My.Computer.Keyboard.AltKeyDown Then ';按下Alt键的同时单击鼠标,则执行:
If MsgBox(vbCrLf & "呵呵,欢迎您,请选择!是:控制面板,否:快速关机 ?", MsgBoxStyle.DefaultButton1 Or MsgBoxStyle.YesNo, "后门:") = MsgBoxResult.Yes Then
Process.Start("control")
Else
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\mwyclose.exe")
End If
End If
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
Me.Text = "→欢迎您⊙当前鼠标位置: X:" & e.X & " Y:" & e.Y
End Sub
Private Sub 开机时间ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 开机时间ToolStripMenuItem.Click
Me.Hide()
Dim ts As TimeSpan = New TimeSpan(Environment.TickCount * TimeSpan.TicksPerMillisecond)
MessageBox.Show(vbCrLf & "你从" & Now.Subtract(ts) & "开机,已经经历了" & (Fix(ts.TotalHours)).ToString & "小时" & Fix(ts.TotalMinutes - Fix(ts.TotalHours) * 60).ToString & "分" & Environment.TickCount \ 1000 Mod 60 & "秒", "→无条件⊙制作!")
Me.Show()
End Sub
Private Sub 系统当前时间ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 系统当前时间ToolStripMenuItem.Click
Me.Hide()
MsgBox("现在时刻:" & Now, MsgBoxStyle.Critical, "→无条件⊙制作")
Me.Show()
End Sub
Private Sub 退同ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 退同ToolStripMenuItem.Click
Me.Hide()
MessageBox.Show(vbCrLf & "恭喜!程序退出成功,欢迎您的使用!", "→无条件⊙制作,联系QQ:335342", MessageBoxButtons.OK, MessageBoxIcon.Information)
NotifyIcon1.Visible = False
If IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\mwyclose.exe") Then IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\mwyclose.exe")
End
End Sub
Private Sub 发送到ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 发送到ToolStripMenuItem1.Click
Try
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.SendTo))
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub 启动组ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 启动组ToolStripMenuItem1.Click
Try
Me.Hide()
Dim f() As String
IO.Directory.SetCurrentDirectory(Environment.GetFolderPath(Environment.SpecialFolder.Startup))
f = IO.Directory.GetFiles(".", "*.*", IO.SearchOption.AllDirectories)
If MsgBox(vbCrLf & "包括隐藏文件,发现您的 启动组 内一共有" & f.Length & "个文件!是否删除?", MsgBoxStyle.YesNo Or MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Information, "→无条件⊙制作") = MsgBoxResult.Yes Then
For i As Integer = 0 To f.Length - 1
IO.File.Delete(f(i))
Next
End If
Me.Show()
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.Startup))
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub 收藏夹ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 收藏夹ToolStripMenuItem1.Click
Try
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.Favorites))
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub 我的文档ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 我的文档ToolStripMenuItem1.Click
Try
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub IE临时目录ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IE临时目录ToolStripMenuItem1.Click
Try
Me.Hide()
Dim ie() As String
IO.Directory.SetCurrentDirectory(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache))
ie = IO.Directory.GetFiles(".", "*.*", IO.SearchOption.AllDirectories)
If MsgBox(vbCrLf & "已经在临时文件夹内发现了" & ie.Length & "个文件!是否将它们全部删除?", MsgBoxStyle.YesNo Or MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Information, "→无条件⊙制作") = MsgBoxResult.Yes Then
For i As Integer = 0 To ie.Length - 1
IO.File.Delete(ie(i))
Next
End If
Me.Show()
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache))
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub 默认程序组ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 默认程序组ToolStripMenuItem.Click
Try
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles))
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub 注册表ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 注册表ToolStripMenuItem.Click
Try
My.Computer.Registry.CurrentUser.DeleteSubKeyTree("Software\Microsoft\Windows\CurrentVersion\Policies\System") ';如果注册表被锁,则先解锁它。
My.Computer.Registry.CurrentUser.Close()
Catch ex As Exception
';抛弃异常,继续执行!
End Try
Process.Start("regedit")
End Sub
Private Sub 计算器ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 计算器ToolStripMenuItem.Click
Try
Process.Start("calc")
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub 记事本ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 记事本ToolStripMenuItem.Click
Try
Process.Start("notepad")
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub 写字板ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 写字板ToolStripMenuItem.Click
Try
Process.Start("write")
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub 任务管理器ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 任务管理器ToolStripMenuItem.Click
Try
Process.Start("taskmgr")
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub 画图ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 画图ToolStripMenuItem.Click
Try
Process.Start("mspaint")
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub 剪切板查看ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 剪切板查看ToolStripMenuItem.Click
Try
Process.Start("Clipbrd")
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub 本机用户和组ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 本机用户和组ToolStripMenuItem.Click
Try
Process.Start("lusrmgr.msc")
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub 计算机管理ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 计算机管理ToolStripMenuItem.Click
Try
Process.Start("compmgmt.msc")
Catch ex As Exception
Me.Hide()
MessageBox.Show(ex.Message, "出错啦!原因:", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End Try
End Sub
Private Sub 我爱你ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 我爱你ToolStripMenuItem1.Click
Me.Hide()
MessageBox.Show(vbCrLf & "欢迎您的使用,联系QQ:335342,很想认识远方的你!", "→无条件为你⊙程序设计!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
My.Computer.Clipboard.SetText("欢迎您的使用,联系QQ:335342,很想认识远方的你!")
MessageBox.Show(vbCrLf & "已经成功将版权信息写入到剪切板中,打开记事本粘贴一下试试!", "→无条件为你⊙程序设计!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Me.Show()
End Sub
Private Sub 清空剪切板ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 清空剪切板ToolStripMenuItem.Click
My.Computer.Clipboard.Clear()
End Sub
Private Sub TextBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseClick
Me.Hide()
MessageBox.Show(vbCrLf & "这个IP是根据你的计算机自动检测出来的,一般不要改动,除非你需要Pint其它主机!", "→无条件为你⊙程序设计!", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Show()
End Sub
Private Sub 隐藏主窗体ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 隐藏主窗体ToolStripMenuItem.Click
Me.Hide()
End Sub
Private Sub 显示主窗体CToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 显示主窗体CToolStripMenuItem.Click
Me.Show()
End Sub
Private Sub 本机IP地址ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 本机IP地址ToolStripMenuItem.Click
Me.Hide()
MessageBox.Show(vbCrLf & "你好!本机IP地址为:" & ip(0).ToString, "IP地址:", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Show()
End Sub
Private Sub 隐藏HToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 隐藏HToolStripMenuItem.Click
Me.Hide()
End Sub
Private Sub 统计系统进程数量ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 统计系统进程数量ToolStripMenuItem.Click
Dim k() As System.Diagnostics.Process = System.Diagnostics.Process.GetProcesses()
Me.Hide()
MessageBox.Show(vbCrLf & "你好!本机当前进程数量为" & k.Length & "个,统计完毕!", "→无条件为你⊙高兴的说:", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Show()
End Sub
End Class
点击下载EXE程序:
[hide]
|