-
程序守护(进程守护)-源代码C#
程序守护(进程守护)-源代码C#
/*
* 由SharpDevelop创建。
* 用户: zhang
* 日期: 2017/3/18
* 时间: 21:50
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using System;
using System.Diagnostics;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
namespace CPinfoSafe
{
public sealed class NotificationIcon
{
private NotifyIcon notifyIcon;
private ContextMenu notificationMenu;
DialogResult dr;
#region Initialize icon and menu
public NotificationIcon()
{
notifyIcon = new NotifyIcon();
notificationMenu = new ContextMenu(InitializeMenu());
notifyIcon.DoubleClick += IconDoubleClick;
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NotificationIcon));
notifyIcon.Icon = (Icon)resources.Get
- 2022-11-01 19:35:03下载
- 积分:1
-
C# 响应新增系统菜单项命令
C# 制作的响应式菜单,响应新增系统菜单项命令,在标题栏单击鼠标右键,会显示出菜单,单击“新增菜单”会响应该菜单的点击,新增了一项自定义的菜单项及命令,实现过程如下:
protected override void WndProc(ref Message SystemMessage)
{//响应新增系统菜单项命令
switch (SystemMessage.Msg)
{
case WM_SYSCOMMAND:
if (((int)SystemMessage.WParam) == WM_USER + 2)
MessageBox.Show("响应新增系统菜单项命令", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
base.WndProc(ref SystemMessage);
break;
default:
base.WndProc(ref SystemMessage);
break;
}
}
- 2022-07-16 20:46:37下载
- 积分:1
-
C# 使用代码查找资源词典中的资源
C# 使用代码查找资源词典中的资源,单击按钮,窗体中会出现一张图片,没搞懂本示例是想要演示什么功能,有兴趣的自己下载源码查看。这里帖一下几行关键代码:
private void button1_Click(object sender, RoutedEventArgs e)
{//使用代码查找资源词典中的资源
Image MyImage = (Image)this.FindResource("MyImage");
this.image1.Source = MyImage.Source;
}
- 2022-09-07 18:30:03下载
- 积分:1
-
Zigbee智能家居完整的源代码
Zigbee智能家居完整的源代码,含有终端和协调器工程并带有汉语注释。非常适合Zigbee开发。-Zigbee Smart Home complete source code, containing the terminal and the coordinator works with Chinese comments. Very suitable for the Zigbee development.
- 2022-03-05 18:50:08下载
- 积分:1
-
C# 使用互斥量禁止程序运行两个实例
C# 使用互斥量禁止程序运行两个实例,这个主要是根据开发的程序使用环境决定,有时候一个程序运行多个副本,会浪费系统资源造成不稳定,但有人说这样会让软件使用更方便,以下代码是不让程序运行多个实例副本,关键代码如下所示:
private void Form1_Load(object sender, EventArgs e)
{//使用互斥量禁止程序运行两个实例
bool bExist;
var MyMutex =new System.Threading.Mutex(true, "OnlyOneTime", out bExist);
if (bExist)
MyMutex.ReleaseMutex();
else
{
MessageBox.Show("程序已经运行!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close();
}
}
- 2022-03-24 02:20:34下载
- 积分:1
-
C# 编写多种窗口排列方式的MDIForm窗体
C# 实现MDIForm窗体功能,代码中实现了3个MDI子窗口,并以水平平铺、垂直平铺、层叠排列的方式实现多种子窗口的排列布局,其主要代码在form1.cs中,其它文件为生成子窗口的文件,关键代码如下:
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();//实例化Form2
frm2.MdiParent = this;//设置MdiParent属性,将当前窗体作为父窗体
frm2.Show();//使用Show方法打开窗体
Form3 frm3 = new Form3();//实例化Form3
frm3.MdiParent = this;//设置MdiParent属性,将当前窗体作为父窗体
frm3.Show();//使用Show方法打开窗体
Form4 frm4 = new Form4();//实例化Form4
frm4.MdiParent = this;//设置MdiParent属性,将当前窗体作为父窗体
frm4.Show();//使用Show方法打开窗体
}
private void 水平平铺ToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.TileHorizontal);//使用MdiLayout枚举实现水平平铺
}
private void 垂直平铺ToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.TileVertical);//使用MdiLayout枚举实现垂直平铺
}
private void 层叠排列ToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.Cascade);//使用MdiLayout枚举实现层叠排列
}
- 2022-03-07 15:00:14下载
- 积分:1
-
C#仿写微信中的打飞机小游戏源码
C#仿写微信中的打飞机小游戏源码,费了好大劲写出来的,感觉比微信中的打飞机要复杂一些,不过本程序还是有Bug的没有修正,主要是退出机制有Bug,单击关闭后,程序还在后台运行,需要通过任务管理器关闭进程,不知道是怎么回事呀,我是折腾够了,留着高手修正吧。以下是相关的代码:
SecondaryBuffer secBuffer;//缓冲区对象
Device secDev;//设备对象
secDev = new Device();
secDev.SetCooperativeLevel(form, CooperativeLevel.Normal);//设置设备协作级别
secBuffer = new SecondaryBuffer(musicPath, secDev);//创建辅助缓冲区
secBuffer.Play(0, BufferPlayFlags.Default);//设置缓冲区为默认播放
- 2023-01-02 17:25:05下载
- 积分:1
-
使用C#的wpf技术生成小球动画效果
使用C#的wpf技术生成小球动画效果,主要是实现小球的移动动画,通过简单的动画,你可了解WPF的作用机理,如何用好WPF来制作更为复杂的动画效果,这个例子过于简单哦,但容易理解。
- 2022-03-22 16:47:54下载
- 积分:1
-
Visual C#创建两个基本的线程(多线程)实例
Visual C#创建两个基本的线程(多线程)实例,为了演示方便,这里把本实例 写成了一个控制台程序,创建两个线程后,通过控制台输出线程信息,演示了两个线程同时工作,下面来看具体代码:
创建两个基本的线程:
Thread thread1 = new Thread(new ThreadStart(Thread1)); //使用自定义方法Thread1声明线程
thread1.Priority = ThreadPriority.Lowest;//设置线程的调度优先级
Thread thread2 = new Thread(new ThreadStart(Thread2)); //使用自定义方法Thread2声明线程
thread1.Start();//开启线程一
thread2.Start();//开启线程二
定义函数向控制台输出线程:
static void Thread1()
{
Console.WriteLine("线程一");
}
输出线程二则可按照上面再创建一个函数,不再列举源码了。
- 2022-03-18 18:55:49下载
- 积分:1
-
C# SelectionStart SelectionEnd时间段选择日历范例
C# Calendar 时间段选择日历范例,可选择时间区间,调用 了C#中的SelectionStart SelectionEnd日期函数实现的功能,这个程序演示了两种功能:
1、获取控件当前的日期和时间
textBox1.Text = monthCalendar1.TodayDate.ToString();
2、时间起始段的选择:
通过SelectionStart属性获取用户选择的起始日期
textBox2.Text = monthCalendar1.SelectionStart.ToString();
通过SelectionEnd属性获取用户选择的结束日期
textBox3.Text = monthCalendar1.SelectionEnd.ToString();
- 2022-08-15 10:37:28下载
- 积分:1