请看到帖子的资深人士帮忙解答一下,希望是用代码实现的。

解决方案 »

  1.   

    ?什么情况?替换windows登录时的壁纸?还是像瑞星一样在登录前就挂个程序?还是仅仅是开机启动程序?
    如果是第三个,这代码够用了
    string starupPath = Application.ExecutablePath;
    RegistryKey loca = Registry.LocalMachine;
    RegistryKey run = loca.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
                try
                {
                    run.SetValue("开机启动", starupPath);
                    MessageBox.Show("注册表添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    loca.Close();
                    run.Close();
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
      

  2.   

    是不是设置开机启动你的程序?
    public static bool SetAutoRun(string keyName,string filePath)
            {
                try
                {
                    RegistryKey runKey=Registry.LocalMachine.OpenSubKey(@"\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",true);
                    runKey.SetValue(keyName,filePath);
                    runKey.Close();
                }
                catch
                {
                    return false;
                }
                return true;
            }调用:第一个参数:起个名字而已
         第二个参数:你的程序的全路径 
    SetAutoRun("myexe","c:\\text.exe");
      

  3.   

    或者copy你的程序的快捷方式到
    C:\Documents and Settings\Administrator\「开始」菜单\程序\启动
      

  4.   


    public enum AutorunType
    {
    LocalMachineRun, CurrentUserRun, LocalMachineShell
    }public static void DisableApplicationAutorun(string displayName, AutorunType autorunType) {            
    if (autorunType == AutorunType.LocalMachineShell)
    {
    Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon");
    regKey.SetValue("Shell", "Explorer.exe");
    regKey.Close();
    }
    else if (autorunType == AutorunType.LocalMachineRun)
    {
    Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
    regKey.DeleteValue(displayName, false);
    regKey.Close();
    }
    else if (autorunType == AutorunType.CurrentUserRun)
    {
    Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
    regKey.DeleteValue(displayName, false);
    regKey.Close();
    }            
    }public static void EnableApplicationAutorun(string displayName, string programFullPathFileName, AutorunType autorunType) {                        
    if (autorunType == AutorunType.LocalMachineShell) {
    Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon");
    regKey.SetValue("Shell", "Explorer.exe " + programFullPathFileName);
    regKey.Close();
    }
    else if (autorunType == AutorunType.LocalMachineRun) {
    Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
    regKey.SetValue(displayName, programFullPathFileName, Microsoft.Win32.RegistryValueKind.String);
    regKey.Close();
    }
    else if (autorunType == AutorunType.CurrentUserRun) {
    Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
    regKey.SetValue(displayName, programFullPathFileName, Microsoft.Win32.RegistryValueKind.String);
    regKey.Close();
    }          

    }
      

  5.   

    请问怎么报错啊!
    :\工作代码文件\DeviceApplication2\DeviceApplication2\Program.cs(21,41): 错误 CS0117: “System.Windows.Forms.Application”并不包含“ExecutablePath”的定义
    E:\工作代码文件\DeviceApplication2\DeviceApplication2\Program.cs(22,9): 错误 CS0246: 找不到类型或命名空间名称“RegistryKey”(是否缺少 using 指令或程序集引用?)
    E:\工作代码文件\DeviceApplication2\DeviceApplication2\Program.cs(22,28): 错误 CS0103: 当前上下文中不存在名称“Registry”
    E:\工作代码文件\DeviceApplication2\DeviceApplication2\Program.cs(23,9): 错误 CS0246: 找不到类型或命名空间名称“RegistryKey”(是否缺少 using 指令或程序集引用?)
    E:\工作代码文件\DeviceApplication2\DeviceApplication2\Program.cs(27,80): 错误 CS0117: “System.Windows.Forms.MessageBoxIcon”并不包含“Information”的定义
    E:\工作代码文件\DeviceApplication2\DeviceApplication2\Program.cs(33,92): 错误 CS0117: “System.Windows.Forms.MessageBoxIcon”并不包含“Error”的定义