• 自动运行


    代码
    using Microsoft.Win32;

    private void Form1_Load(object sender, EventArgs e)
    {
        //获取程序执行路径..
        string starupPath = Application.ExecutablePath;
        //class Micosoft.Win32.RegistryKey. 表示Window注册表中项级节点,此类是注册表装.
        RegistryKey loca = Registry.LocalMachine;
        RegistryKey run = loca.CreateSubKey(@"SOFTWAREMicrosoftWindowsCurrentVersionRun");
       
        try
        {
           //SetValue:存储值的名称
     run.SetValue("WinForm",starupPath);
     MessageBox.Show(" 注册表添加成功!!",""提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
            loca.Close();
        }
        catch(Exception ee)
        {
            MessageBox.Show(ee.Message.ToString(),"提 示",MessageBoxButtons.OK,MessageBoxIcon.Error);
        }
    }

    第二种方法:
    添加到注册表里直接用代码写到注册表里,也可以手动添加.
    E:D:\tractor.exe//可以是你的程序名和 完整路径就OK了.
    也可以手动拖到启动里面....

    自动运行、代码
    RegistryKey hklm = Application.LocalMachine;
     RegistryKey run = hklm.CreateSubKey(@"SOFTWAREMicrosoftWindowsCurrentVersionRun");
     try
     {
        run.SetValue("tractor.exe","D:\tractor.exe");
        MessageBox.Show("注册表添加成功!!","提示",MessageBoxButton.OK, MessageBoxIcon.Information);
        hklm.Close();
     }

     catch(Exception ee)
     {
        MessageBox.Show(my.Message.ToString(),"提示",MessageBoxButton.OK, MessageBoxIcon.Error);
      }
  • 相关阅读:
    将数字转换千分位分隔形式
    根据字符分割字符串的三种写法
    取出字符串中的汉字、字母或是数字
    生成n位随机字符串
    python中类的继承
    汇编语言与计算机体系结构
    DMA(direct memory access)直接内存访问
    数学归纳法证明时间复杂度
    具体名词的理解、单词的深意
    python的类和对象
  • 原文地址:https://www.cnblogs.com/accumulater/p/6088637.html
Copyright © 2020-2023  润新知