Старт(удаление) приложения при запуске Windows
На форму поместите 2 CommandButton. При нажатии на первую кнопку, ссылка на запуск вашего приложения будет размещена в реестре. Вторая кнопка удалит вашу программу из автозагрузки
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Sub AddToStartup(ByVal sDesc As String, ByVal sFile As String)
Dim lRegKey As Long
RegOpenKey HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", lRegKey
If lRegKey Then
RegSetValueEx lRegKey, sDesc, 0, 1, ByVal sFile, Len(sApp)
RegCloseKey lRegKey
End If
End Sub
Private Function DeleteAtStartup(ByVal strValue As String)
Dim keyhand As Long
r = RegOpenKey(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", keyhand)
r = RegDeleteValue(keyhand, strValue)
r = RegCloseKey(keyhand)
End Function
Private Sub Command1_Click()
AddToStartup "Моя программа", "C:\soft\MyProg.exe"
End Sub
Private Sub Command2_Click()
DeleteAtStartup "Моя программа"
End Sub
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 93