用C#编写的记事本,将它设为文本的默认启动程序 用C#编写的记事本,将它设为文本的默认启动程序后,双击文本(*.txt)后将文本内容显示出来,应该怎么做?请多指教!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 写注册表 。Microsoft.Win32.RegexKey. google “注册表 文件关联” 一个是注册表关联,这个上面说了,还有一个就是在 void Main(string[] Args)中通过 Args获取双击传入的文件名:MessageBox.Show(string.Join(",", Args)); //你可以试试看,这里可以获得你打开了什么文件 #region 写入程序相关 private void WriteApp() { //设置程序打开路径 string path = "\"C:\\Users\\Administrator\\Desktop\\Test\\TestWinForm\\bin\\Debug\\TestWinForm.exe\""; RegistryKey root = Registry.ClassesRoot; RegistryKey f1 = root.CreateSubKey("Form1"); //设置注册表程序打开的项与值,其中SetValue("", path)代表设置默认值 f1.CreateSubKey("shell").CreateSubKey("Open").CreateSubKey("Command").SetValue("", path); //设置程序图标 string ico = "\"C:\\Users\\Administrator\\Desktop\\u7_original.ico\""; f1.CreateSubKey("DefaultIcon").SetValue("", ico); } #endregion #region 写关联文件 private void WriteRelate() { RegistryKey root = Registry.ClassesRoot; //设置打开程序 root.CreateSubKey(".cws").CreateSubKey("OpenWithProgids").SetValue("Form1",""); } #endregion把注册表的记事本路径改了就OK ; 在注册表里设置文件关联,把 txt文件打开的默认程序设为你的程序 shell ContextMenu 注册文件右键http://topic.csdn.net/u/20100830/16/04688fb1-62e9-427f-839a-e3aa4e1232cb.html HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\OpenWithProgidsOpenWithList这个下面 求System.Windows.Forms.dll里各控件图标打包 反射:用构造函数动态生成对象 win2000,无法找到动态链接库,怎么回事呢? 算法问题,如何计算子字符串在那个位置最为集中? 我今天刚刚到这个里面来 麻烦各位看下这2题怎么写~~~ 一个数据库表如何分成两表在显示 如何用C#获取远程LINUX主机的CPU、内存等使用量啊? ViewState和Session比较? 模式子窗口关闭,主窗口显示 请问在C#中怎么使用我已经做好的报表文件CrystalReport1.rpt? C#模拟掌上百度登录贴吧 在VS2010中利用WPF 4 Ribbon 开发RibbonWindow
Microsoft.Win32.RegexKey.
MessageBox.Show(string.Join(",", Args)); //你可以试试看,这里可以获得你打开了什么文件
private void WriteApp()
{
//设置程序打开路径
string path = "\"C:\\Users\\Administrator\\Desktop\\Test\\TestWinForm\\bin\\Debug\\TestWinForm.exe\"";
RegistryKey root = Registry.ClassesRoot;
RegistryKey f1 = root.CreateSubKey("Form1");
//设置注册表程序打开的项与值,其中SetValue("", path)代表设置默认值
f1.CreateSubKey("shell").CreateSubKey("Open").CreateSubKey("Command").SetValue("", path);
//设置程序图标
string ico = "\"C:\\Users\\Administrator\\Desktop\\u7_original.ico\"";
f1.CreateSubKey("DefaultIcon").SetValue("", ico);
}
#endregion
#region 写关联文件
private void WriteRelate()
{
RegistryKey root = Registry.ClassesRoot;
//设置打开程序
root.CreateSubKey(".cws").CreateSubKey("OpenWithProgids").SetValue("Form1","");
}
#endregion把注册表的记事本路径改了就OK ;
把 txt文件打开的默认程序设为你的程序
http://topic.csdn.net/u/20100830/16/04688fb1-62e9-427f-839a-e3aa4e1232cb.html
OpenWithProgids
OpenWithList这个下面