English 中文(简体)
如何启动我的方案?
原标题:How to make my program run at startup?
  • 时间:2009-09-04 06:26:11
  •  标签:

Im式节目设计一个类似于谷歌台的台式应用,但与我自己的甘子一起使用2008年电网,当用户在其电脑上安装时,如何使我提出申请?

让我假设,我的应用名称是窗口Aplication1和Im,使用窗口XP,方案将安装在C车上?

问题回答

您可以在登记处添加以下代码:

My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWAREMicrosoftWindowsCurrentVersionRun", True).SetValue(Application.ProductName, Application.ExecutablePath)

您可以删除。

My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWAREMicrosoftWindowsCurrentVersionRun", True).DeleteValue(Application.ProductName)

上述法典将向所有用户添加。 您可以在以下关键方面向目前用户添加这一信息:

HKEY_CURRENT_USERSOFTWAREMicrosoftWindowsCurrentVersionRun

或者,你可以与你在“标准”夹中的应用联系起来。

我建议你自动这样做,可能刺激用户。 我在看到他们自动加入“Windowsstartup”时表示仇恨。 选择用户在窗口启动时实施方案。

简单使用该守则:

Dim info As New FileInfo(application.startuppath)
info.CopyTo(My.Computer.FileSystem.SpecialDirectories.Programs + "startupmyapp.exe")

希望它能够提供帮助。

页: 1 采用以下守则

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

      This is where you ll need to have the program
      set the check box to the previous selection that
      the user has set. It s up to you how you do this.
      For now, I ll set it as "unchecked".

    CheckBox1.Checked = False

  End Sub

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

      The following code is a rendition of one provided by
      Firestarter_75, so he gets the credit here:

    Dim applicationName As String = Application.ProductName
    Dim applicationPath As String = Application.ExecutablePath

    If CheckBox1.Checked Then
      Dim regKey As Microsoft.Win32.RegistryKey
      regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWAREMicrosoftWindowsCurrentVersionRun", True)
      regKey.SetValue(applicationName, """" & applicationPath & """")
      regKey.Close()
    Else
      Dim regKey As Microsoft.Win32.RegistryKey
      regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWAREMicrosoftWindowsCurrentVersionRun", True)
      regKey.DeleteValue(applicationName, False)
      regKey.Close()
    End If

      Assuming that you ll run this as a setup form of some sort
      and call it using .ShowDialog, simply close this form to
      return to the main program
    Close()
    End Sub
Imports Microsoft.Win32

...

Registry.SetValue("HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionRun", Application.ProductName, Application.ExecutablePath, RegistryValueKind.String)

简单方法

Imports Microsoft.Win32

...

Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWAREMicrosoftWindowsCurrentVersionRun",True)
regKey.SetValue(Application.ProductName, Application.ExecutablePath)
regKey.Close()

希望会有助于

Just Trial this Code:-

FileCopy("Name.Ext", Environment.GetFolderPath(Environment.SpecialFolder.Startup) & "Name.Ext")

页: 1

Name - Your Application s name. Ext - The Extension, it s of-course .exe

它最简单、最能使用。

Might be old topic but adding Imports System.Security.AccessControl.RegistryRights Should resolve System.Security.SecurityException: Requested registry access is not allowed. trouble stated by Christhofer Natalius





相关问题
热门标签