zoukankan      html  css  js  c++  java
  • 注册表文件关联

     1       #region 写入程序相关
    2 private void WriteApp()
    3 {
    4 //设置程序打开路径
    5 string path = "\"C:\\Users\\Administrator\\Desktop\\Test\\TestWinForm\\bin\\Debug\\TestWinForm.exe\"";
    6 RegistryKey root = Registry.ClassesRoot;
    7 RegistryKey f1 = root.CreateSubKey("Form1");
    8 //设置注册表程序打开的项与值,其中SetValue("", path)代表设置默认值
    9 f1.CreateSubKey("shell").CreateSubKey("Open").CreateSubKey("Command").SetValue("", path);
    10
    11 //设置程序图标
    12 string ico = "\"C:\\Users\\Administrator\\Desktop\\u7_original.ico\"";
    13 f1.CreateSubKey("DefaultIcon").SetValue("", ico);
    14 }
    15 #endregion
    16
    17 #region 写关联文件
    18 private void WriteRelate()
    19 {
    20 RegistryKey root = Registry.ClassesRoot;
    21 //设置打开程序
    22 root.CreateSubKey(".cws").CreateSubKey("OpenWithProgids").SetValue("Form1","");
    23 }
    24 #endregion
    code in my life.
  • 相关阅读:
    155. 最小栈
    160. 相交链表
    PAT 1057 Stack
    PAT 1026 Table Tennis
    PAT 1017 Queueing at Bank
    PAT 1014 Waiting in Line
    PAT 1029 Median
    PAT 1016 Phone Bills
    PAT 1010 Radix
    PAT 1122 Hamiltonian Cycle
  • 原文地址:https://www.cnblogs.com/ghypnus/p/2433089.html
Copyright © 2011-2022 走看看