模拟win7运行窗体C#源码
来源:互联网 发布:淘宝客佣金设置技巧 编辑:程序博客网 时间:2024/06/06 00:45
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
namespace 运行
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/// <summary>
/// 存放运行过的文件
/// </summary>
List<string> lstPath = new List<string>();
//浏览
private void btnBrowse_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog()==DialogResult.OK)
{
this.cboPath.Text = openFileDialog1.FileName;
}
}
//取消
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
//确定
private void btnAscertain_Click(object sender, EventArgs e)
{
try
{
Process.Start(cboPath.Text);
lstPath.Add(cboPath.Text);
this.Close();
}
catch (Exception)
{
MessageBox.Show("Windows找不到文件'"+cboPath.Text+"'。请确定文件名是否正确后,在试一次。",cboPath.Text,MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
private void cboPath_TextChanged(object sender, EventArgs e)
{
if (cboPath.Text.Trim()=="")
{
btnAscertain.Enabled = false;
}
else
{
btnAscertain.Enabled = true;
}
}
//退出时序列化文件
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
FileStream fs = new FileStream(@"C:/Windows/yunxing.bin", FileMode.Create);//改成你喜欢的路径
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, lstPath);
fs.Close();
}
//加载时读取
private void Form1_Load(object sender, EventArgs e)
{
if (File.Exists(@"C:/Windows/yunxing.bin"))
{
try
{
FileStream fs = new FileStream("yunxing.bin", FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
lstPath = (List<string>)bf.Deserialize(fs);
fs.Close();
for (int i = lstPath.Count - 1; i >= 0; i--)
{
cboPath.Items.Add(lstPath[i]);
}
cboPath.Text = lstPath[lstPath.Count - 1];
}
catch (Exception)
{
//不处理异常
}
}
this.Location = new Point(0,Screen.GetWorkingArea(this).Height-this.Height);
}
}
}
【程序效果图】
- 模拟win7运行窗体C#源码
- C#窗体程序在win7下运行时 控件无win7 方式
- C#模拟窗体系统菜单
- C#模拟MSN窗体抖动
- C#模拟MSN窗体抖动
- C#模拟MSN窗体抖动
- C#模拟QQ窗体抖动
- C#模拟MSN窗体抖动
- C#模拟MSN窗体抖动
- C# 模拟WIN7水泡屏保(弹球模拟)
- C#窗体运行的唯一性问题
- 【WPF】C#获取运行的窗体标题
- Linux 运行C#窗体应用程序 mono
- C#实现在运行窗体中拖拽组件
- C# Winform窗体自动运行隐藏
- C#透明窗体(png图片渐变)源码
- C#实现在窗体标题栏加入按钮(好像不支持WIN7)
- C# Winform 窗体美化(七、Win7 Aero 毛玻璃效果)
- 编程大师论道:PHP的魅力和不足何在
- C#中对DatagridView部分常用操作
- 使用WinAPI写的小串口(不完善无法接收)
- HTML5:实至名归还是言过其实?
- Android画图之Matrix(一)
- 模拟win7运行窗体C#源码
- 总结SQL手工注入方法
- 收获的一天!
- 【其他】【RQNOJ】单词查找树
- 不要去在乎的24件事
- 机械迷城中的一个游戏—— C#代码
- Linux下C++程序中的内存泄露检查
- 平台+App,还是桌面+浏览器?
- 浅析编写C#多线程