首页 > 编程学习 > C# Windows Mobile 6 通过注册表实现开机自运行
2010九月28

C# Windows Mobile 6 通过注册表实现开机自运行

方法1:制作CAB安装包

VS2005,新建项目–其他项目类型–安装和部署–智能Cab安装项目–在Program files里增加文件夹myexe

添加要可执行 a.exe。

打开注册表视图,在HKEY_LOCAL_MACHINE 增加 Init 文件夹,新建字符串 Launch98,值为

“\Program files\myexe\a.exe”

这样,安装cab之后重启下即可自运行。

private void Form1_Activated(object sender, EventArgs e)
        {
            this.Hide();  //隐藏窗体
        }

方法2:通过程序运行注册键值

 

  //注册开机
  //Registry.LocalMachine 对应于 HKEY_LOCAL_MACHINE主键
  RegistryKey key = Registry.LocalMachine.OpenSubKey("init", true);
  if (key.GetValue("Launch77") == null)
  {
       key.SetValue("Launch77", Assembly.GetExecutingAssembly().GetName().CodeBase);
       MessageBox.Show("注册成功!", "提示");
   }
   key.Close();

Loading

本文地址:https://wizzer.cn/archives/1182 , 转载请保留.

本文目前尚无任何评论.

发表评论