Visual Basic - Agregar programa en carpeta inicio

Life is soft - evento anual de software empresarial
 
Vista:

Agregar programa en carpeta inicio

Publicado por Mauro (45 intervenciones) el 20/02/2004 15:44:41
Como hago para que cuando se ejecute mi programa, se coloque el ejecutable en la carpeta incio, o comprobar si existe no se agrega, y si no existe se agrega.
Desde ya muchas gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Agregar programa en carpeta inicio

Publicado por Cecilia Colalongo (3116 intervenciones) el 20/02/2004 17:20:12
Puedes crear o bien un acceso directo a tu ejecutable o copiarlo en la carpeta de Inicio o agregarlo en HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run

Para preguntar si existe o no, puedes revisar con la función Dir si el archivo (.exe) o acceso directo (.lnk) está o no en el directorio.

Para crear un acceso directo en la carpeta de Inicio:

Set loShell=CreateObject("wscript.Shell")
Set loShortcut=loShell.CreateShortcut(CarpetaInicio+"\MiAccesoDirecto.lnk")
With loShortcut
.TargetPath="MiAplicacion.exe"
.WorkingDirectory="DirectorioDeTrabajo"
.Save
End With

Para determinar la carpeta del inicio:

Const CSIDL_DESKTOP = &H7
Const MAX_PATH = 260
Private Type SHITEMID
cb As Long
abID As Byte
End Type
Private Type ITEMIDLIST
mkid As SHITEMID
End Type
Private Declare Function ShellAbout Lib "shell32.dll" Alias "ShellAboutA" (ByVal hWnd As Long, ByVal szApp As String, ByVal szOtherStuff As String, ByVal hIcon As Long) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Function GetSpecialfolder(CSIDL As Long) As String
Dim r As Long
Dim IDL As ITEMIDLIST
r = SHGetSpecialFolderLocation(100, CSIDL, IDL)
If r = NOERROR Then
Path$ = Space$(512)
r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal Path$)
GetSpecialfolder = Left$(Path, InStr(Path, Chr$(0)) - 1)
Exit Function
End If
GetSpecialfolder = ""
End Function
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar