- Код: Выделить всё
'Декларация
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
RegSetValueEx lRegKey, sDesc, 1, 1, ByVal sFile, Len(sApp)
RegCloseKey lRegKey
End Sub
Private Sub Command1_Click()
AddToStartup "calc", "c:\calc.exe"
AddToStartup "calc", "c:\calc.exe"
End Sub
но в реестре создается только название ключа, а параметра, в данном случае пути к программе ничего не записывает
windows Xp, sp1, vb6