右键新建->你喜欢的文件
来源:互联网 发布:python 判断编码格式 编辑:程序博客网 时间:2024/05/02 13:56
大家都知道在桌面右键可以新建文件,但是谁知道如何新建自己喜欢的文件呢?
本程序给你答案。
代码如下:
private void btnSure_Click(object sender, EventArgs e)
{
if (textBox1.Text.Trim() == "" || textBox2.Text.Trim() == "" || textBox3.Text.Trim() == "" || textBox4.Text.Trim() == "")
{
MessageBox.Show("输入有误请重新输入!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBox4.Focus();
return;
}
RegistryKey key1 = Registry.ClassesRoot.CreateSubKey(textBox4.Text);
key1.SetValue("",textBox1.Text);
RegistryKey key2 = key1.CreateSubKey("ShellNew");
key2.SetValue("NullFile","");
key1.Close();
key2.Close();
key1 = Registry.ClassesRoot.CreateSubKey(textBox1.Text);
key1.SetValue("",textBox1.Text+"文件");
key2 = key1.CreateSubKey("DefaultIcon");
key2.SetValue("",textBox3.Text+",1");
key2.Close();
key2 = key1.CreateSubKey("shell//open//command");
key2.SetValue("",textBox2.Text);
MessageBox.Show("自定义文件添加完毕!", "ok", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void btnLogOff_Click(object sender, EventArgs e)
{
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";//调用cmd执行dos命令
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;//是否显示cmd窗口
process.Start();
process.StandardInput.WriteLine("shutdown.exe -l");
process.StandardInput.WriteLine("exit");
}
输入信息后,点击注销。重新登录到window后就可以新建你刚才输入的文件类型了。
其实本程序的实质是对注册表的操作。
下载请到:http://liuyuehui110.download.csdn.net/
- 右键新建->你喜欢的文件
- [原创]你绝对喜欢的FlashGet右键菜单
- win8右键无法新建文件
- Windows右键新建md文件
- 右键新建97-03版本的doc,xls.ppt文件
- 删除Win7中鼠标右键多余的新建文件项
- 桌面右键“新建”菜单中乱七八糟的文件太多怎么办?
- Office2013无法在鼠标右键中新建文件的解决办法
- 解决 Windows 右键无法新建文件问题的方法
- win7右键的新建文本文档不见了,无法新建txt文件
- 右键菜单“新建”的修改
- 我喜欢的你
- 【你会喜欢的~~】
- windos右键找不到新建文件选项
- Ubuntu右键菜单添加新建OpenOffice文件
- 右键添加新建TXT文件注册表
- 解决fedora下右键没有新建文件
- 解决fedora下右键没有新建文件
- 世界名牌大学课件下载地址
- 我的学习梦
- 编写一个程序设计一个汽车类vehicle,包含的私有数据成员有车轮个数wheels和车重weight
- 前路漫漫
- 身份证号码验证正则表达式
- 右键新建->你喜欢的文件
- 乐乐....
- 这大概也算是成功的捷径
- 常见JAVA虚拟机命令行参数用法介绍
- 彩虹天堂
- C#,C++,js类型分类表(转)
- c# ADO
- 古代八大笑星
- 新人报到