Ciao
per effettuare lo Start Up, ovvero l'esecuzione di un programma all'avvio, dovresti comportarti in tale modo
inserire un Modulo, quindi un File (Bas)
con queste stringhe
Attribute VB_Name = "StartUp"
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Function mfncGetFromIni(strSectionHeader As String, strVariableName As String, strFileName As String) As String
Dim strReturn As String
strReturn = String(255, Chr(0))
mfncGetFromIni = Left$(strReturn, GetPrivateProfileString(strSectionHeader, ByVal strVariableName, "", strReturn, Len(strReturn), strFileName))
End Function
Function mfncWriteIni(strSectionHeader As String, strVariableName As String, strValue As String, strFileName As String) As Integer
mfncWriteIni = WritePrivateProfileString(strSectionHeader, strVariableName, strValue, strFileName)
End Function
Function WindowsDir() As String
Dim WindirS As String * 255
Dim Temp
Dim Result
Temp = GetWindowsDirectory(WindirS, 255)
Result = Left(WindirS, Temp)
WindowsDir = Result
End Function
e nel Progetto
Public Sub RegRunService(Path As String, Keyname As String)
'Ex: RegRun "C:/MyProgram.exe", "MyProgram"
Dim Reg As Object
Set Reg = CreateObject("wscript.shell")
Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUNSERVICES\" & Keyname, Path
End Sub
Spero ti sia chiaro!!!
Se ci sono dei dubbi.. POSTA!!!
B. Fine Settimana
Ultima modifica effettuata da il 10/03/2007 alle 19:32 |