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()
FullPathAndFileName = App.Path
If Right(App.Path, 1) <> "\" Then FullPathAndFileName = FullPathAndFileName & "\"
FullPathAndFileName = FullPathAndFileName & App.EXEName & ".exe"
AddToStartup "Моя программа", FullPathAndFileName = 1
End Sub
Private Sub Command2_Click()
DeleteAtStartup "Моя программа"
End Sub
Вот должен же путь файла прописаться!
P.S. Спасибо вам за то, что помогаете.