zoukankan      html  css  js  c++  java
  • 自动运行

    代码
    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);
      }
  • 相关阅读:
    用mkdirs创建目录
    关于布局(Layout)的一切
    用HTTP操作和文件操作把网页下载到sd卡
    OpenStack计费项目Cloudkitty系列详解(一)
    OpenStack/Gnocchi简介——时间序列数据聚合操作提前计算并存储起来,先算后取的理念
    python-RabbitMQ
    1go基本语法
    openstack多region配置
    cinder 挂载卷和 iSCSI原理
    Host aggregate分区
  • 原文地址:https://www.cnblogs.com/accumulater/p/6088637.html
Copyright © 2011-2022 走看看