elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  Añadir a Favoritos del panel de navegación del explorer
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Añadir a Favoritos del panel de navegación del explorer  (Leído 2,870 veces)
Car0nte

Desconectado Desconectado

Mensajes: 21


Ver Perfil
Añadir a Favoritos del panel de navegación del explorer
« en: 16 Febrero 2014, 04:45 am »

Buenas,

Estoy acabando una pequeña aplicación y como remate me gustaría poder añadirla a los favoritos del panel de navegación del explorer, no a la carpeta de favoritos de Windows sino a los favoritos que aparecen normalmente a la izquierda del explorador de Windows.

Es para una aplicación en NET, pero como supongo que se haga a través del registro o de donde sea y no encuentro absolutamente nada que no sea hacerlos desaparecer del explorador, posteo aquí porque imagino que pueda ser una solución común.

Saludos y gracias


En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Añadir a Favoritos del panel de navegación del explorer
« Respuesta #1 en: 16 Febrero 2014, 14:23 pm »

Hola

Las preguntas sobre .NET van en el subforo .NET.

Supongo que te refieres a las ubicaciones favoritas?:



No se hace mediante el registro, símplemente son accesos directos que se guardan en el directorio del perfil del usuario actual, en C:\Users\USUARIO\Links

Solo necesitas crear un acceso directo.

Te hice este ejemplo (en VB.NET) para crear un acceso directo de la aplicación actual en el directorio de los favoritos del panel de navegación:

Código
  1. Imports System.IO
  2.  
  3. Public Class Form1
  4.  
  5.    ''' <summary>
  6.    ''' La ruta del directorio del acceso directo que quieres crear.
  7.    ''' </summary>
  8.    ReadOnly ShortcutDir As String =
  9.        Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Links")
  10.  
  11.    ''' <summary>
  12.    ''' El nombre del archivo de acceso directo.
  13.    ''' </summary>
  14.    ReadOnly ShortcutName As String =
  15.        "MyProgram.lnk"
  16.  
  17.    ReadOnly FileInfo As FileInfo =
  18.        New FileInfo(Path.Combine(My.Application.Info.DirectoryPath(),
  19.                                  Process.GetCurrentProcess().MainModule.ModuleName))
  20.  
  21.    Private Shadows Sub Load() Handles MyBase.Load
  22.  
  23.        Dim Shortcut As New ShortcutManager.ShortcutInfo
  24.  
  25.        With Shortcut
  26.  
  27.            .ShortcutFile = Path.Combine(ShortcutDir, ShortcutName)
  28.            .Target = FileInfo.FullName
  29.            .Arguments = Nothing
  30.            .WorkingDir = FileInfo.DirectoryName
  31.            .Description = "MyProgram"
  32.            .Icon = FileInfo.FullName
  33.            .IconIndex = 0
  34.            .WindowState = ShortcutManager.ShortcutWindowState.Normal
  35.  
  36.        End With
  37.  
  38.        ShortcutManager.CreateShortcut(Shortcut)
  39.  
  40.    End Sub
  41.  
  42. End Class

...Usando el ayudante que escribí:

Código
  1. ' ***********************************************************************
  2. ' Author   : Elektro
  3. ' Modified : 02-16-2014
  4. ' ***********************************************************************
  5. ' <copyright file="ShortcutManager.vb" company="Elektro Studios">
  6. '     Copyright (c) Elektro Studios. All rights reserved.
  7. ' </copyright>
  8. ' ***********************************************************************
  9.  
  10. #Region " Imports "
  11.  
  12. Imports System.Runtime.InteropServices
  13. Imports System.Text
  14. Imports System.IO
  15.  
  16. #End Region
  17.  
  18. #Region " ShortcutManager "
  19.  
  20. ''' <summary>
  21. ''' Performs Shortcut related operations.
  22. ''' </summary>
  23. Public Class ShortcutManager
  24.  
  25. #Region " Variables "
  26.  
  27.    Private Shared lnk As New ShellLink()
  28.    Private Shared lnk_data As New WIN32_FIND_DATAW()
  29.  
  30.    Private Shared lnk_arguments As New StringBuilder(260)
  31.    Private Shared lnk_description As New StringBuilder(260)
  32.    Private Shared lnk_target As New StringBuilder(260)
  33.    Private Shared lnk_workingdir As New StringBuilder(260)
  34.    Private Shared lnk_iconpath As New StringBuilder(260)
  35.    Private Shared lnk_iconindex As Integer = -1
  36.    Private Shared lnk_hotkey As Short = -1
  37.    Private Shared lnk_windowstate As ShortcutWindowState = ShortcutWindowState.Normal
  38.  
  39. #End Region
  40.  
  41. #Region " P/Invoke "
  42.  
  43.    <DllImport("shfolder.dll", CharSet:=CharSet.Auto)>
  44.    Private Shared Function SHGetFolderPath(
  45.           ByVal hwndOwner As IntPtr,
  46.           ByVal nFolder As Integer,
  47.           ByVal hToken As IntPtr,
  48.           ByVal dwFlags As Integer,
  49.           ByVal lpszPath As StringBuilder
  50.    ) As Integer
  51.    End Function
  52.  
  53.    <Flags()>
  54.    Private Enum SLGP_FLAGS
  55.  
  56.        ''' <summary>
  57.        ''' Retrieves the standard short (8.3 format) file name.
  58.        ''' </summary>
  59.        SLGP_SHORTPATH = &H1
  60.  
  61.        ''' <summary>
  62.        ''' Retrieves the Universal Naming Convention (UNC) path name of the file.
  63.        ''' </summary>
  64.        SLGP_UNCPRIORITY = &H2
  65.  
  66.        ''' <summary>
  67.        ''' Retrieves the raw path name.
  68.        ''' A raw path is something that might not exist and may include environment variables that need to be expanded.
  69.        ''' </summary>
  70.        SLGP_RAWPATH = &H4
  71.  
  72.    End Enum
  73.  
  74.    <Flags()>
  75.    Private Enum SLR_FLAGS
  76.  
  77.        ''' <summary>
  78.        ''' Do not display a dialog box if the link cannot be resolved. When SLR_NO_UI is set,
  79.        ''' the high-order word of fFlags can be set to a time-out value that specifies the
  80.        ''' maximum amount of time to be spent resolving the link. The function returns if the
  81.        ''' link cannot be resolved within the time-out duration. If the high-order word is set
  82.        ''' to zero, the time-out duration will be set to the default value of 3,000 milliseconds
  83.        ''' (3 seconds). To specify a value, set the high word of fFlags to the desired time-out
  84.        ''' duration, in milliseconds.
  85.        ''' </summary>
  86.        SLR_NO_UI = &H1
  87.  
  88.        ''' <summary>
  89.        ''' If the link object has changed, update its path and list of identifiers.
  90.        ''' If SLR_UPDATE is set, you do not need to call IPersistFile::IsDirty to determine,
  91.        ''' whether or not the link object has changed.
  92.        ''' </summary>
  93.        SLR_UPDATE = &H4
  94.  
  95.        ''' <summary>
  96.        ''' Do not update the link information
  97.        ''' </summary>
  98.        SLR_NOUPDATE = &H8
  99.  
  100.        ''' <summary>
  101.        ''' Do not execute the search heuristics
  102.        ''' </summary>
  103.        SLR_NOSEARCH = &H10
  104.  
  105.        ''' <summary>
  106.        ''' Do not use distributed link tracking
  107.        ''' </summary>
  108.        SLR_NOTRACK = &H20
  109.  
  110.        ''' <summary>
  111.        ''' Disable distributed link tracking.
  112.        ''' By default, distributed link tracking tracks removable media,
  113.        ''' across multiple devices based on the volume name.
  114.        ''' It also uses the Universal Naming Convention (UNC) path to track remote file systems,
  115.        ''' whose drive letter has changed.
  116.        ''' Setting SLR_NOLINKINFO disables both types of tracking.
  117.        ''' </summary>
  118.        SLR_NOLINKINFO = &H40
  119.  
  120.        ''' <summary>
  121.        ''' Call the Microsoft Windows Installer
  122.        ''' </summary>
  123.        SLR_INVOKE_MSI = &H80
  124.  
  125.    End Enum
  126.  
  127.    ''' <summary>
  128.    ''' Stores information about a shortcut file.
  129.    ''' </summary>
  130.    Public Class ShortcutInfo
  131.  
  132.        ''' <summary>
  133.        ''' Shortcut file full path.
  134.        ''' </summary>
  135.        Public Property ShortcutFile As String
  136.  
  137.        ''' <summary>
  138.        ''' Shortcut Comment/Description.
  139.        ''' </summary>
  140.        Public Property Description As String
  141.  
  142.        ''' <summary>
  143.        ''' Shortcut Target Arguments.
  144.        ''' </summary>
  145.        Public Property Arguments As String
  146.  
  147.        ''' <summary>
  148.        ''' Shortcut Target.
  149.        ''' </summary>
  150.        Public Property Target As String
  151.  
  152.        ''' <summary>
  153.        ''' Shortcut Working Directory.
  154.        ''' </summary>
  155.        Public Property WorkingDir As String
  156.  
  157.        ''' <summary>
  158.        ''' Shortcut Icon Location.
  159.        ''' </summary>
  160.        Public Property Icon As String
  161.  
  162.        ''' <summary>
  163.        ''' Shortcut Icon Index.
  164.        ''' </summary>
  165.        Public Property IconIndex As Integer
  166.  
  167.        ''' <summary>
  168.        ''' Shortcut Hotkey combination.
  169.        ''' Is represented as Hexadecimal.
  170.        ''' </summary>
  171.        Public Property Hotkey As Short
  172.  
  173.        ''' <summary>
  174.        ''' Shortcut Hotkey modifiers.
  175.        ''' </summary>
  176.        Public Property Hotkey_Modifier As HotkeyModifiers
  177.  
  178.        ''' <summary>
  179.        ''' Shortcut Hotkey Combination.
  180.        ''' </summary>
  181.        Public Property Hotkey_Key As Keys
  182.  
  183.        ''' <summary>
  184.        ''' Shortcut Window State.
  185.        ''' </summary>
  186.        Public Property WindowState As ShortcutWindowState
  187.  
  188.        ''' <summary>
  189.        ''' Indicates if the target is a file.
  190.        ''' </summary>
  191.        Public Property IsFile As Boolean
  192.  
  193.        ''' <summary>
  194.        ''' Indicates if the target is a directory.
  195.        ''' </summary>
  196.        Public Property IsDirectory As Boolean
  197.  
  198.        ''' <summary>
  199.        ''' Shortcut target drive letter.
  200.        ''' </summary>
  201.        Public Property DriveLetter As String
  202.  
  203.        ''' <summary>
  204.        ''' Shortcut target directory name.
  205.        ''' </summary>
  206.        Public Property DirectoryName As String
  207.  
  208.        ''' <summary>
  209.        ''' Shortcut target filename.
  210.        ''' (File extension is not included in name)
  211.        ''' </summary>
  212.        Public Property FileName As String
  213.  
  214.        ''' <summary>
  215.        ''' Shortcut target file extension.
  216.        ''' </summary>
  217.        Public Property FileExtension As String
  218.  
  219.    End Class
  220.  
  221.    ''' <summary>
  222.    ''' Hotkey modifiers for a shortcut file.
  223.    ''' </summary>
  224.    <Flags()>
  225.    Public Enum HotkeyModifiers As Short
  226.  
  227.        ''' <summary>
  228.        ''' The SHIFT key.
  229.        ''' </summary>
  230.        SHIFT = 1
  231.  
  232.        ''' <summary>
  233.        ''' The CTRL key.
  234.        ''' </summary>
  235.        CONTROL = 2
  236.  
  237.        ''' <summary>
  238.        ''' The ALT key.
  239.        ''' </summary>
  240.        ALT = 4
  241.  
  242.        ''' <summary>
  243.        ''' None.
  244.        ''' Specifies any hotkey modificator.
  245.        ''' </summary>
  246.        NONE = 0
  247.  
  248.    End Enum
  249.  
  250.    ''' <summary>
  251.    ''' The Window States for a shortcut file.
  252.    ''' </summary>
  253.    Public Enum ShortcutWindowState As Integer
  254.  
  255.        ''' <summary>
  256.        ''' Shortcut Window is at normal state.
  257.        ''' </summary>
  258.        Normal = 1
  259.  
  260.        ''' <summary>
  261.        ''' Shortcut Window is Maximized.
  262.        ''' </summary>
  263.        Maximized = 3
  264.  
  265.        ''' <summary>
  266.        ''' Shortcut Window is Minimized.
  267.        ''' </summary>
  268.        Minimized = 7
  269.  
  270.    End Enum
  271.  
  272.    <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)>
  273.    Private Structure WIN32_FIND_DATAW
  274.        Public dwFileAttributes As UInteger
  275.        Public ftCreationTime As Long
  276.        Public ftLastAccessTime As Long
  277.        Public ftLastWriteTime As Long
  278.        Public nFileSizeHigh As UInteger
  279.        Public nFileSizeLow As UInteger
  280.        Public dwReserved0 As UInteger
  281.        Public dwReserved1 As UInteger
  282.        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)>
  283.        Public cFileName As String
  284.        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=14)>
  285.        Public cAlternateFileName As String
  286.    End Structure
  287.  
  288.    ''' <summary>
  289.    ''' The IShellLink interface allows Shell links to be created, modified, and resolved
  290.    ''' </summary>
  291.    <ComImport(),
  292.    InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
  293.    Guid("000214F9-0000-0000-C000-000000000046")>
  294.    Private Interface IShellLinkW
  295.  
  296.        ''' <summary>
  297.        ''' Retrieves the path and file name of a Shell link object.
  298.        ''' </summary>
  299.        Sub GetPath(<Out(), MarshalAs(UnmanagedType.LPWStr)>
  300.                    ByVal pszFile As StringBuilder,
  301.                    ByVal cchMaxPath As Integer,
  302.                    ByRef pfd As WIN32_FIND_DATAW,
  303.                    ByVal fFlags As SLGP_FLAGS)
  304.  
  305.        ''' <summary>
  306.        ''' Retrieves the list of item identifiers for a Shell link object.
  307.        ''' </summary>
  308.        Sub GetIDList(ByRef ppidl As IntPtr)
  309.  
  310.        ''' <summary>
  311.        ''' Sets the pointer to an item identifier list (PIDL) for a Shell link object.
  312.        ''' </summary>
  313.        Sub SetIDList(ByVal pidl As IntPtr)
  314.  
  315.        ''' <summary>
  316.        ''' Retrieves the description string for a Shell link object.
  317.        ''' </summary>
  318.        Sub GetDescription(<Out(), MarshalAs(UnmanagedType.LPWStr)>
  319.                           ByVal pszName As StringBuilder,
  320.                           ByVal cchMaxName As Integer)
  321.  
  322.        ''' <summary>
  323.        ''' Sets the description for a Shell link object.
  324.        ''' The description can be any application-defined string.
  325.        ''' </summary>
  326.        Sub SetDescription(<MarshalAs(UnmanagedType.LPWStr)>
  327.                           ByVal pszName As String)
  328.  
  329.        ''' <summary>
  330.        ''' Retrieves the name of the working directory for a Shell link object.
  331.        ''' </summary>
  332.        Sub GetWorkingDirectory(<Out(), MarshalAs(UnmanagedType.LPWStr)>
  333.                                ByVal pszDir As StringBuilder,
  334.                                ByVal cchMaxPath As Integer)
  335.  
  336.        ''' <summary>
  337.        ''' Sets the name of the working directory for a Shell link object.
  338.        ''' </summary>
  339.        Sub SetWorkingDirectory(<MarshalAs(UnmanagedType.LPWStr)>
  340.                                ByVal pszDir As String)
  341.  
  342.        ''' <summary>
  343.        ''' Retrieves the command-line arguments associated with a Shell link object.
  344.        ''' </summary>
  345.        Sub GetArguments(<Out(), MarshalAs(UnmanagedType.LPWStr)>
  346.                         ByVal pszArgs As StringBuilder,
  347.                         ByVal cchMaxPath As Integer)
  348.  
  349.        ''' <summary>
  350.        ''' Sets the command-line arguments for a Shell link object.
  351.        ''' </summary>
  352.        Sub SetArguments(<MarshalAs(UnmanagedType.LPWStr)>
  353.                         ByVal pszArgs As String)
  354.  
  355.        ''' <summary>
  356.        ''' Retrieves the hot key for a Shell link object.
  357.        ''' </summary>
  358.        Sub GetHotkey(ByRef pwHotkey As Short)
  359.  
  360.        ''' <summary>
  361.        ''' Sets a hot key for a Shell link object.
  362.        ''' </summary>
  363.        Sub SetHotkey(ByVal wHotkey As Short)
  364.  
  365.        ''' <summary>
  366.        ''' Retrieves the show command for a Shell link object.
  367.        ''' </summary>
  368.        Sub GetShowCmd(ByRef piShowCmd As Integer)
  369.  
  370.        ''' <summary>
  371.        ''' Sets the show command for a Shell link object.
  372.        ''' The show command sets the initial show state of the window.
  373.        ''' </summary>
  374.        Sub SetShowCmd(ByVal iShowCmd As ShortcutWindowState)
  375.  
  376.        ''' <summary>
  377.        ''' Retrieves the location (path and index) of the icon for a Shell link object.
  378.        ''' </summary>
  379.        Sub GetIconLocation(<Out(), MarshalAs(UnmanagedType.LPWStr)>
  380.                            ByVal pszIconPath As StringBuilder,
  381.                            ByVal cchIconPath As Integer,
  382.                            ByRef piIcon As Integer)
  383.  
  384.        ''' <summary>
  385.        ''' Sets the location (path and index) of the icon for a Shell link object.
  386.        ''' </summary>
  387.        Sub SetIconLocation(<MarshalAs(UnmanagedType.LPWStr)>
  388.                            ByVal pszIconPath As String,
  389.                            ByVal iIcon As Integer)
  390.  
  391.        ''' <summary>
  392.        ''' Sets the relative path to the Shell link object.
  393.        ''' </summary>
  394.        Sub SetRelativePath(<MarshalAs(UnmanagedType.LPWStr)>
  395.                            ByVal pszPathRel As String,
  396.                            ByVal dwReserved As Integer)
  397.  
  398.        ''' <summary>
  399.        ''' Attempts to find the target of a Shell link,
  400.        ''' even if it has been moved or renamed.
  401.        ''' </summary>
  402.        Sub Resolve(ByVal hwnd As IntPtr,
  403.                    ByVal fFlags As SLR_FLAGS)
  404.  
  405.        ''' <summary>
  406.        ''' Sets the path and file name of a Shell link object
  407.        ''' </summary>
  408.        Sub SetPath(ByVal pszFile As String)
  409.  
  410.    End Interface
  411.  
  412.    <ComImport(), Guid("0000010c-0000-0000-c000-000000000046"),
  413.    InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>
  414.    Private Interface IPersist
  415.  
  416.        <PreserveSig()>
  417.        Sub GetClassID(ByRef pClassID As Guid)
  418.  
  419.    End Interface
  420.  
  421.    <ComImport(), Guid("0000010b-0000-0000-C000-000000000046"),
  422.    InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>
  423.    Private Interface IPersistFile
  424.        Inherits IPersist
  425.  
  426.        Shadows Sub GetClassID(ByRef pClassID As Guid)
  427.  
  428.        <PreserveSig()>
  429.        Function IsDirty() As Integer
  430.  
  431.        <PreserveSig()>
  432.        Sub Load(<[In](), MarshalAs(UnmanagedType.LPWStr)>
  433.                 pszFileName As String,
  434.                 dwMode As UInteger)
  435.  
  436.        <PreserveSig()>
  437.        Sub Save(<[In](), MarshalAs(UnmanagedType.LPWStr)>
  438.                 pszFileName As String,
  439.                 <[In](), MarshalAs(UnmanagedType.Bool)>
  440.                 fRemember As Boolean)
  441.  
  442.        <PreserveSig()>
  443.        Sub SaveCompleted(<[In](), MarshalAs(UnmanagedType.LPWStr)>
  444.                          pszFileName As String)
  445.  
  446.        <PreserveSig()>
  447.        Sub GetCurFile(<[In](), MarshalAs(UnmanagedType.LPWStr)>
  448.                       ppszFileName As String)
  449.  
  450.    End Interface
  451.  
  452.    ' "CLSID_ShellLink" from "ShlGuid.h"
  453.    <ComImport(),
  454.    Guid("00021401-0000-0000-C000-000000000046")>
  455.    Private Class ShellLink
  456.    End Class
  457.  
  458. #End Region
  459.  
  460. #Region " Public Methods "
  461.  
  462.    ''' <summary>
  463.    ''' Resolves the target of a shortcut.
  464.    ''' If shortcut can't be resolved, an error message would be displayed.
  465.    ''' This is usefull when the target path of a shortcut file is changed from a driveletter for example,
  466.    ''' then the shortcut file need to be resolved before trying to retrieve the target path.
  467.    ''' </summary>
  468.    ''' <param name="ShortcutFile">
  469.    ''' The shortcut file to resolve.
  470.    ''' </param>
  471.    ''' <param name="hwnd">
  472.    ''' The new handle pointer that would be generated
  473.    ''' for the window which should display the error message (if any).
  474.    ''' </param>
  475.    Public Shared Sub ResolveUi(ShortcutFile As String, hwnd As IntPtr)
  476.        LoadShortcut(ShortcutFile)
  477.        DirectCast(lnk, IShellLinkW).Resolve(hwnd, SLR_FLAGS.SLR_UPDATE)
  478.    End Sub
  479.  
  480.    ''' <summary>
  481.    ''' Resolves the target of a shortcut.
  482.    ''' If shortcut can't be resolved, any error message would be displayed.
  483.    ''' This is usefull when the target path of a shortcut file is changed from a driveletter for example,
  484.    ''' then the shortcut file need to be resolved before trying to retrieve the target path.
  485.    ''' </summary>
  486.    ''' <param name="ShortcutFile">
  487.    ''' The shortcut file to resolve.
  488.    ''' </param>
  489.    Public Shared Sub ResolveNoUi(ByVal ShortcutFile As String)
  490.        LoadShortcut(ShortcutFile)
  491.        DirectCast(lnk, IShellLinkW).Resolve(IntPtr.Zero, SLR_FLAGS.SLR_UPDATE Or SLR_FLAGS.SLR_NO_UI)
  492.    End Sub
  493.  
  494.    ''' <summary>
  495.    ''' Returns the description of a shortcut file.
  496.    ''' </summary>
  497.    ''' <param name="ShortcutFile">
  498.    ''' The shortcut file to retrieve the info.
  499.    ''' </param>
  500.    Public Shared Function GetDescription(ByVal ShortcutFile As String) As String
  501.        LoadShortcut(ShortcutFile)
  502.        lnk_description.Clear()
  503.        DirectCast(lnk, IShellLinkW).GetDescription(lnk_description, lnk_description.Capacity)
  504.        Return lnk_description.ToString()
  505.    End Function
  506.  
  507.    ''' <summary>
  508.    ''' Returns the Arguments of a shortcut file.
  509.    ''' </summary>
  510.    ''' <param name="ShortcutFile">
  511.    ''' The shortcut file to retrieve the info.
  512.    ''' </param>
  513.    Public Shared Function GetArguments(ByVal ShortcutFile As String) As String
  514.        LoadShortcut(ShortcutFile)
  515.        lnk_arguments.Clear()
  516.        DirectCast(lnk, IShellLinkW).GetArguments(lnk_arguments, lnk_arguments.Capacity)
  517.        Return lnk_arguments.ToString()
  518.    End Function
  519.  
  520.    ''' <summary>
  521.    ''' Returns the path and filename of a shortcut file.
  522.    ''' </summary>
  523.    ''' <param name="ShortcutFile">
  524.    ''' The shortcut file to retrieve the info.
  525.    ''' </param>
  526.    Public Shared Function GetFullPath(ByVal ShortcutFile As String) As String
  527.        LoadShortcut(ShortcutFile)
  528.        lnk_target.Clear()
  529.        DirectCast(lnk, IShellLinkW).GetPath(lnk_target, lnk_target.Capacity, lnk_data, SLGP_FLAGS.SLGP_UNCPRIORITY)
  530.        Return lnk_target.ToString()
  531.    End Function
  532.  
  533.    ''' <summary>
  534.    ''' Returns the working directory of a shortcut file.
  535.    ''' </summary>
  536.    ''' <param name="ShortcutFile">
  537.    ''' The shortcut file to retrieve the info.
  538.    ''' </param>
  539.    Public Shared Function GetWorkingDir(ByVal ShortcutFile As String) As String
  540.        LoadShortcut(ShortcutFile)
  541.        lnk_workingdir.Clear()
  542.        DirectCast(lnk, IShellLinkW).GetWorkingDirectory(lnk_workingdir, lnk_workingdir.Capacity)
  543.        Return lnk_workingdir.ToString()
  544.    End Function
  545.  
  546.    ''' <summary>
  547.    ''' Returns the Hotkey of a shortcut file.
  548.    ''' </summary>
  549.    ''' <param name="ShortcutFile">
  550.    ''' The shortcut file to retrieve the info.
  551.    ''' </param>
  552.    Public Shared Function GetHotkey(ByVal ShortcutFile As String) As Short
  553.        LoadShortcut(ShortcutFile)
  554.        lnk_hotkey = -1
  555.        DirectCast(lnk, IShellLinkW).GetHotkey(lnk_hotkey)
  556.        Return lnk_hotkey
  557.    End Function
  558.  
  559.    ''' <summary>
  560.    ''' Returns the Window State of a shortcut file.
  561.    ''' </summary>
  562.    ''' <param name="ShortcutFile">
  563.    ''' The shortcut file to retrieve the info.
  564.    ''' </param>
  565.    Public Shared Function GetWindowStyle(ByVal ShortcutFile As String) As ShortcutWindowState
  566.        LoadShortcut(ShortcutFile)
  567.        DirectCast(lnk, IShellLinkW).GetShowCmd(lnk_windowstate)
  568.        Return lnk_windowstate
  569.    End Function
  570.  
  571.    ''' <summary>
  572.    ''' Returns the Icon location of a shortcut file.
  573.    ''' </summary>
  574.    ''' <param name="ShortcutFile">
  575.    ''' The shortcut file to retrieve the info.
  576.    ''' </param>
  577.    ''' <param name="IconIndex">
  578.    ''' Optional Integer type variable to store the IconIndex.
  579.    ''' </param>
  580.    Public Shared Function GetIconLocation(ByVal ShortcutFile As String,
  581.                                            Optional ByRef IconIndex As Integer = 0) As String
  582.        LoadShortcut(ShortcutFile)
  583.        lnk_iconpath.Clear()
  584.        DirectCast(lnk, IShellLinkW).GetIconLocation(lnk_iconpath, lnk_iconpath.Capacity, IconIndex)
  585.        Return lnk_iconpath.ToString()
  586.    End Function
  587.  
  588.    ''' <summary>
  589.    ''' Retrieves all the information about a shortcut file.
  590.    ''' </summary>
  591.    ''' <param name="ShortcutFile">
  592.    ''' The shortcut file to retrieve the info.
  593.    ''' </param>
  594.    Public Shared Function GetInfo(ByVal ShortcutFile As String) As ShortcutInfo
  595.  
  596.        ' Load Shortcut
  597.        LoadShortcut(ShortcutFile)
  598.  
  599.        ' Clean objects
  600.        Clean()
  601.  
  602.        ' Retrieve Shortcut Info
  603.        DirectCast(lnk, IShellLinkW).GetDescription(lnk_description, lnk_description.Capacity)
  604.        DirectCast(lnk, IShellLinkW).GetArguments(lnk_arguments, lnk_arguments.Capacity)
  605.        DirectCast(lnk, IShellLinkW).GetPath(lnk_target, lnk_target.Capacity, lnk_data, SLGP_FLAGS.SLGP_UNCPRIORITY)
  606.        DirectCast(lnk, IShellLinkW).GetWorkingDirectory(lnk_workingdir, lnk_workingdir.Capacity)
  607.        DirectCast(lnk, IShellLinkW).GetIconLocation(lnk_iconpath, lnk_iconpath.Capacity, lnk_iconindex)
  608.        DirectCast(lnk, IShellLinkW).GetHotkey(lnk_hotkey)
  609.        DirectCast(lnk, IShellLinkW).GetShowCmd(lnk_windowstate)
  610.  
  611.        ' Return Shortcut Info
  612.        Return New ShortcutInfo With {
  613.            .ShortcutFile = ShortcutFile,
  614.            .Description = lnk_description.ToString,
  615.            .Arguments = lnk_arguments.ToString,
  616.            .Target = lnk_target.ToString,
  617.            .Icon = lnk_iconpath.ToString,
  618.            .IconIndex = lnk_iconindex,
  619.            .WorkingDir = lnk_workingdir.ToString,
  620.            .Hotkey = Hex(lnk_hotkey),
  621.            .Hotkey_Modifier = [Enum].Parse(GetType(HotkeyModifiers), GetHiByte(lnk_hotkey)),
  622.            .Hotkey_Key = [Enum].Parse(GetType(Keys), GetLoByte(lnk_hotkey)),
  623.            .WindowState = lnk_windowstate,
  624.            .IsFile = File.Exists(lnk_target.ToString),
  625.            .IsDirectory = Directory.Exists(lnk_target.ToString),
  626.            .DriveLetter = lnk_target.ToString.Substring(0, 1),
  627.            .DirectoryName = lnk_target.ToString.Substring(0, lnk_target.ToString.LastIndexOf("\")),
  628.            .FileName = lnk_target.ToString.Split("\").LastOrDefault.Split(".").FirstOrDefault,
  629.            .FileExtension = lnk_target.ToString.Split(".").LastOrDefault
  630.        }
  631.  
  632.    End Function
  633.  
  634.    ''' <summary>
  635.    ''' Creates a shortcut file.
  636.    ''' </summary>
  637.    ''' <param name="FilePath">
  638.    ''' The filepath to create the shortcut.
  639.    ''' </param>
  640.    ''' <param name="Target">
  641.    ''' The target file or directory.
  642.    ''' </param>
  643.    ''' <param name="WorkingDirectory">
  644.    ''' The working directory os the shortcut.
  645.    ''' </param>
  646.    ''' <param name="Description">
  647.    ''' The shortcut description.
  648.    ''' </param>
  649.    ''' <param name="Arguments">
  650.    ''' The target file arguments.
  651.    ''' This value only should be set when target is an executable file.
  652.    ''' </param>
  653.    ''' <param name="Icon">
  654.    ''' The icon location of the shortcut.
  655.    ''' </param>
  656.    ''' <param name="IconIndex">
  657.    ''' The icon index of the icon file.
  658.    ''' </param>
  659.    ''' <param name="HotKey_Modifier">
  660.    ''' The hotkey modifier(s) which should be used for the hotkey combination.
  661.    ''' <paramref name="HotkeyModifiers"/> can be one or more modifiers.
  662.    ''' </param>
  663.    ''' <param name="HotKey_Key">
  664.    ''' The key used in combination with the <paramref name="HotkeyModifiers"/> for hotkey combination.
  665.    ''' </param>
  666.    ''' <param name="WindowState">
  667.    ''' The Window state for the target.
  668.    ''' </param>
  669.    Public Shared Sub CreateShortcut(ByVal FilePath As String,
  670.                                     ByVal Target As String,
  671.                                     Optional ByVal WorkingDirectory As String = Nothing,
  672.                                     Optional ByVal Description As String = Nothing,
  673.                                     Optional ByVal Arguments As String = Nothing,
  674.                                     Optional ByVal Icon As String = Nothing,
  675.                                     Optional ByVal IconIndex As Integer = Nothing,
  676.                                     Optional ByVal HotKey_Modifier As HotkeyModifiers = Nothing,
  677.                                     Optional ByVal HotKey_Key As Keys = Nothing,
  678.                                     Optional ByVal WindowState As ShortcutWindowState = ShortcutWindowState.Normal)
  679.  
  680.        ' Load Shortcut
  681.        LoadShortcut(FilePath)
  682.  
  683.        ' Clean objects
  684.        Clean()
  685.  
  686.        ' Set Shortcut Info
  687.        DirectCast(lnk, IShellLinkW).SetPath(Target)
  688.  
  689.        DirectCast(lnk, IShellLinkW).SetWorkingDirectory(If(WorkingDirectory IsNot Nothing,
  690.                                                            WorkingDirectory,
  691.                                                            Path.GetDirectoryName(Target)))
  692.  
  693.        DirectCast(lnk, IShellLinkW).SetDescription(Description)
  694.        DirectCast(lnk, IShellLinkW).SetArguments(Arguments)
  695.        DirectCast(lnk, IShellLinkW).SetIconLocation(Icon, IconIndex)
  696.  
  697.        DirectCast(lnk, IShellLinkW).SetHotkey(If(HotKey_Modifier + HotKey_Key <> 0,
  698.                                                  Convert.ToInt16(CInt(HotKey_Modifier & Hex(HotKey_Key)), 16),
  699.                                                  Nothing))
  700.  
  701.        DirectCast(lnk, IShellLinkW).SetShowCmd(WindowState)
  702.  
  703.        DirectCast(lnk, IPersistFile).Save(FilePath, True)
  704.        DirectCast(lnk, IPersistFile).SaveCompleted(FilePath)
  705.  
  706.    End Sub
  707.  
  708.    ''' <summary>
  709.    ''' Creates a shortcut file.
  710.    ''' </summary>
  711.    ''' <param name="Shortcut">Indicates a ShortcutInfo object.</param>
  712.    Public Shared Sub CreateShortcut(ByVal Shortcut As ShortcutInfo)
  713.  
  714.        CreateShortcut(Shortcut.ShortcutFile,
  715.                       Shortcut.Target,
  716.                       Shortcut.WorkingDir,
  717.                       Shortcut.Description,
  718.                       Shortcut.Arguments,
  719.                       Shortcut.Icon,
  720.                       Shortcut.IconIndex,
  721.                       Shortcut.Hotkey_Modifier,
  722.                       Shortcut.Hotkey_Key,
  723.                       Shortcut.WindowState)
  724.  
  725.    End Sub
  726.  
  727.    ''' <summary>
  728.    ''' Modifies the atributes of an existing shortcut file.
  729.    ''' </summary>
  730.    ''' <param name="ShortcutFile">
  731.    ''' The existing .lnk file to modify.
  732.    ''' </param>
  733.    ''' <param name="Target">
  734.    ''' The target file or directory.
  735.    ''' </param>
  736.    ''' <param name="WorkingDirectory">
  737.    ''' The working directory os the shortcut.
  738.    ''' </param>
  739.    ''' <param name="Description">
  740.    ''' The shortcut description.
  741.    ''' </param>
  742.    ''' <param name="Arguments">
  743.    ''' The target file arguments.
  744.    ''' This value only should be set when target is an executable file.
  745.    ''' </param>
  746.    ''' <param name="Icon">
  747.    ''' The icon location of the shortcut.
  748.    ''' </param>
  749.    ''' <param name="IconIndex">
  750.    ''' The icon index of the icon file.
  751.    ''' </param>
  752.    ''' <param name="HotKey_Modifier">
  753.    ''' The hotkey modifier(s) which should be used for the hotkey combination.
  754.    ''' <paramref name="HotkeyModifiers"/> can be one or more modifiers.
  755.    ''' </param>
  756.    ''' <param name="HotKey_Key">
  757.    ''' The key used in combination with the <paramref name="HotkeyModifiers"/> for hotkey combination.
  758.    ''' </param>
  759.    ''' <param name="WindowState">
  760.    ''' The Window state for the target.
  761.    ''' </param>
  762.    Public Shared Sub ModifyShortcut(ByVal ShortcutFile As String,
  763.                                     Optional ByVal Target As String = Nothing,
  764.                                     Optional ByVal WorkingDirectory As String = Nothing,
  765.                                     Optional ByVal Description As String = Nothing,
  766.                                     Optional ByVal Arguments As String = Nothing,
  767.                                     Optional ByVal Icon As String = Nothing,
  768.                                     Optional ByVal IconIndex As Integer = -1,
  769.                                     Optional ByVal HotKey_Modifier As HotkeyModifiers = -1,
  770.                                     Optional ByVal HotKey_Key As Keys = -1,
  771.                                     Optional ByVal WindowState As ShortcutWindowState = -1)
  772.  
  773.        ' Load Shortcut
  774.        LoadShortcut(ShortcutFile)
  775.  
  776.        ' Clean objects
  777.        Clean()
  778.  
  779.        ' Retrieve Shortcut Info
  780.        DirectCast(lnk, IShellLinkW).GetDescription(lnk_description, lnk_description.Capacity)
  781.        DirectCast(lnk, IShellLinkW).GetArguments(lnk_arguments, lnk_arguments.Capacity)
  782.        DirectCast(lnk, IShellLinkW).GetPath(lnk_target, lnk_target.Capacity, lnk_data, SLGP_FLAGS.SLGP_UNCPRIORITY)
  783.        DirectCast(lnk, IShellLinkW).GetWorkingDirectory(lnk_workingdir, lnk_workingdir.Capacity)
  784.        DirectCast(lnk, IShellLinkW).GetIconLocation(lnk_iconpath, lnk_iconpath.Capacity, lnk_iconindex)
  785.        DirectCast(lnk, IShellLinkW).GetHotkey(lnk_hotkey)
  786.        DirectCast(lnk, IShellLinkW).GetShowCmd(lnk_windowstate)
  787.  
  788.        ' Set Shortcut Info
  789.        DirectCast(lnk, IShellLinkW).SetPath(If(Target IsNot Nothing,
  790.                                                Target,
  791.                                                lnk_target.ToString))
  792.  
  793.        DirectCast(lnk, IShellLinkW).SetWorkingDirectory(If(WorkingDirectory IsNot Nothing,
  794.                                                            WorkingDirectory,
  795.                                                            lnk_workingdir.ToString))
  796.  
  797.        DirectCast(lnk, IShellLinkW).SetDescription(If(Description IsNot Nothing,
  798.                                                       Description,
  799.                                                       lnk_description.ToString))
  800.  
  801.        DirectCast(lnk, IShellLinkW).SetArguments(If(Arguments IsNot Nothing,
  802.                                                     Arguments,
  803.                                                     lnk_arguments.ToString))
  804.  
  805.        DirectCast(lnk, IShellLinkW).SetIconLocation(If(Icon IsNot Nothing, Icon, lnk_iconpath.ToString),
  806.                                                     If(IconIndex <> -1, IconIndex, lnk_iconindex))
  807.  
  808.        DirectCast(lnk, IShellLinkW).SetHotkey(If(HotKey_Modifier + HotKey_Key > 0,
  809.                                                  Convert.ToInt16(CInt(HotKey_Modifier & Hex(HotKey_Key)), 16),
  810.                                                  lnk_hotkey))
  811.  
  812.        DirectCast(lnk, IShellLinkW).SetShowCmd(If(WindowState <> -1,
  813.                                                   WindowState,
  814.                                                   lnk_windowstate))
  815.  
  816.        DirectCast(lnk, IPersistFile).Save(ShortcutFile, True)
  817.        DirectCast(lnk, IPersistFile).SaveCompleted(ShortcutFile)
  818.  
  819.  
  820.    End Sub
  821.  
  822. #End Region
  823.  
  824. #Region " Private Methods "
  825.  
  826.    ''' <summary>
  827.    ''' Loads the shortcut object to retrieve information.
  828.    ''' </summary>
  829.    ''' <param name="ShortcutFile">
  830.    ''' The shortcut file to retrieve the info.
  831.    ''' </param>
  832.    Private Shared Sub LoadShortcut(ByVal ShortcutFile As String)
  833.        DirectCast(lnk, IPersistFile).Load(ShortcutFile, 0)
  834.    End Sub
  835.  
  836.    ''' <summary>
  837.    ''' Clean the shortcut info objects.
  838.    ''' </summary>
  839.    Private Shared Sub Clean()
  840.        lnk_description.Clear()
  841.        lnk_arguments.Clear()
  842.        lnk_target.Clear()
  843.        lnk_workingdir.Clear()
  844.        lnk_iconpath.Clear()
  845.        lnk_hotkey = -1
  846.        lnk_iconindex = -1
  847.    End Sub
  848.  
  849.    ''' <summary>
  850.    ''' Gets the low order byte of a number.
  851.    ''' </summary>
  852.    Private Shared Function GetLoByte(ByVal Intg As Integer) As Integer
  853.        Return Intg And &HFF&
  854.    End Function
  855.  
  856.    ''' <summary>
  857.    ''' Gets the high order byte of a number.
  858.    ''' </summary>
  859.    Private Shared Function GetHiByte(ByVal Intg As Integer) As Integer
  860.        Return (Intg And &HFF00&) / 256
  861.    End Function
  862.  
  863. #End Region
  864.  
  865. End Class
  866.  
  867. #End Region


« Última modificación: 16 Febrero 2014, 14:36 pm por Eleкtro » En línea

Car0nte

Desconectado Desconectado

Mensajes: 21


Ver Perfil
Re: Añadir a Favoritos del panel de navegación del explorer
« Respuesta #2 en: 16 Febrero 2014, 17:52 pm »

JodX"#!@!!! xDDD

Citar
No se hace mediante el registro, símplemente son accesos directos que se guardan en el directorio del perfil del usuario actual, en C:\Users\USUARIO\Links

GRACIAS, de verdad... ERA EXACTAMENTE ESO LO QUE BUSCABA me estaba volviendo loco. Ayer me tire dos horas buscando en el registro, carpetas especiales, etc y no caí en los Links

Por eso postee en este foro en vez del de net o el específico de VB. Imagianaba que la solución estaba en el registro o en alguna carpeta, aunque siendo sincero ya había tirado la toalla con las carpetas especiales... se me pasó!

Gracias por el pedazo de código que te has marcado, No conocía esa forma de crear Shorcuts (lo copio con tu permiso) Yo tiraba de la shell de WS

Pego la función que cree por si a alguien le sirve:

Código
  1.    Function CreadorAD(ByVal Directorio As String)
  2.  
  3.        Dim ScriptShell, DirectorioShell, EnlaceShell As Object
  4.  
  5.        Try
  6.  
  7.            ScriptShell = CreateObject("WScript.Shell")
  8.  
  9.            If Directorio = "Escritorio" Then
  10.  
  11.                Dim DirEscritorio As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
  12.  
  13.                DirectorioShell = DirEscritorio
  14.  
  15.            ElseIf Directorio = "Inicio" Then
  16.  
  17.                Dim DirInicio As String = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu)
  18.  
  19.                DirectorioShell = DirInicio
  20.  
  21.            ElseIf Directorio = "Favoritos" Then
  22.  
  23.                Dim DirFavoritos As String = Environment.GetFolderPath(Environment.SpecialFolder.Favorites)
  24.  
  25.                DirectorioShell = DirFavoritos
  26.  
  27.            ElseIf Directorio = "FavoritosPanel" Then
  28.  
  29.                Dim DirUsuario As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
  30.                Dim DirLink1 As String = "\Links"
  31.  
  32.                If CompruebaDir(DirUsuario & DirLink1) = True Then
  33.  
  34.                    DirectorioShell = DirUsuario & DirLink1
  35.  
  36.                Else
  37.  
  38.                    DirLink1 = "\Vínculos"
  39.                    DirectorioShell = DirUsuario & DirLink1
  40.  
  41.                End If
  42.  
  43.            ElseIf Directorio = "InicioWin" Then
  44.  
  45.                Dim DirInicioWin As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
  46.  
  47.                DirectorioShell = DirInicioWin
  48.  
  49.            Else : DirectorioShell = Directorio
  50.  
  51.            End If
  52.  
  53.            If CompruebaArchivo(DirectorioShell & "\" & My.Application.Info.ProductName & ".lnk") = True Then
  54.  
  55.                MsgBox("El acceso directo que se pretende crear ya existe en " & DirectorioShell, _
  56.                       MsgBoxStyle.Information)
  57.  
  58.                Return False
  59.                Exit Function
  60.  
  61.            Else
  62.  
  63.                Dim Respuesta As MsgBoxResult
  64.  
  65.                Respuesta = MsgBox("A continuación se creará un acceso directo en " & DirectorioShell & _
  66.                                   vbCrLf & vbCrLf & "¿Desea activar la ejecución mediante un a" & _
  67.                                   "tajo?" & vbCrLf & "Esto significa que podrá llamar al Progr" & _
  68.                                   "amador pulsando " & Chr(34) & "ALT + P" & Chr(34), _
  69.                                   MsgBoxStyle.Question + MsgBoxStyle.YesNoCancel)
  70.  
  71.                If Not Respuesta = MsgBoxResult.Cancel Then
  72.  
  73.  
  74.                    EnlaceShell = ScriptShell.CreateShortcut(DirectorioShell & "\" & My.Application.Info.ProductName & ".lnk")
  75.  
  76.                    EnlaceShell.TargetPath = Application.ExecutablePath
  77.                    EnlaceShell.Description = My.Application.Info.ProductName
  78.                    EnlaceShell.WindowStyle = 1
  79.  
  80.                    If Respuesta = MsgBoxResult.Yes Then EnlaceShell.Hotkey = "Alt+p"
  81.  
  82.                    EnlaceShell.Save()
  83.  
  84.                    If CompruebaArchivo(DirectorioShell & "\" & My.Application.Info.ProductName & ".lnk") = True Then
  85.  
  86.                        MsgBox("El acceso directo ha sido creado con éxito en " & DirectorioShell, _
  87.                               MsgBoxStyle.Information, "Creación de acceso directo")
  88.  
  89.                    Else : MsgBox("Ocurrió un error durante el proceso" & vbCrLf & vbCrLf & _
  90.                                  "El acceso directo no ha sido creado", MsgBoxStyle.Critical, _
  91.                                  "Error")
  92.                    End If
  93.                Else
  94.  
  95.                    MsgBox("Se ha cancelado la creación del acceso directo en " & DirectorioShell, _
  96.                           MsgBoxStyle.Information, "Operación cancelada")
  97.                    Return False
  98.                    Exit Function
  99.  
  100.                End If
  101.  
  102.            End If
  103.  
  104.        Catch ex As Exception
  105.  
  106.            MsgBox(ex.Message & vbCrLf & vbCrLf & "En caso de que requiera pemisos administrati" & _
  107.                   "vos, consulte con el administrador del sistema", MsgBoxStyle.Critical, "Error")
  108.  
  109.        End Try
  110.  
  111.        Return True
  112.  
  113.    End Function
  114.  

Las otras dos funciones citadas son:

Código
  1.    Function CompruebaDir(ByVal Directorio As String, Optional ByVal Explicación As Boolean = False)
  2.  
  3.        If IO.Directory.Exists(Directorio) Then
  4.  
  5.            Return True
  6.  
  7.        Else
  8.  
  9.            Return False
  10.            If Explicación = True Then MsgBox("El directorio especificado no existe", _
  11.                MsgBoxStyle.Exclamation, "Comprobación directorio")
  12.  
  13.        End If
  14.  
  15.    End Function
  16.  
  17.    Function CompruebaArchivo(ByVal Archivo As String, Optional ByVal Explicación As Boolean = False)
  18.  
  19.            If IO.File.Exists(Archivo) Then
  20.  
  21.                Return True
  22.  
  23.            Else
  24.  
  25.                Return False
  26.                If Explicación = True Then MsgBox("El archivo especificado no existe", _
  27.                    MsgBoxStyle.Exclamation, "Comprobación Archivo")
  28.  
  29.            End If
  30.  
  31.    End Function

Saludos y GRACIAS

PD: Elektro, estoy probando tu código y me da problemas con ShortcutManager.ShortcutInfo Será cosa mía... echaré un vistazo en msdn. Has propocionado material para un buen rato :)

EDITADO:

Añadido "Links" a la función

EDITADO (2):

Añadidas correcciones
« Última modificación: 20 Febrero 2014, 03:59 am por Car0nte » En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Añadir a Favoritos del panel de navegación del explorer
« Respuesta #3 en: 16 Febrero 2014, 18:33 pm »

La verdad es que si la intención es sólamente crear un shortcut pues no vale la pena añadir a tu proyecto una Class de 1.000 lineas de código y taladrarse la cabeza investigando en MSDN sobre esas interfaces y demás, lo típico es hacerlo como has mostrado tú, aunque prácticamente es lo mismo, pero el código lo escribí hace ya tiempo para manejar más que la creación de shortcuts, en realidad la idea fue resolver shortcuts y lo de la creación/modificación de shortcuts lo añadí como algo secundario y para evitar dependencias innecesarias de WScript.

PD: Elektro, estoy probando tu código y me da problemas con ShortcutManager.ShortcutInfo Será cosa mía... echaré un vistazo en msdn.

Me resulta extraño porque el miembro 'ShortcutInfo' sólamente es una Class con propiedades públicas,
en cada propiedad debes especificar los valores del shortcut que quieres crear (aunque algunas de las propiedades como 'IsFile' o 'IsFolder' no importa lo que pongas porque las uso para otros métodos) que luego toma el método 'CreateShortcut', al que le añadí un 'Overload' para poder pasarle un objeto 'ShortcutInfo', pero si te da problemas, en lugar de pasarle un 'ShortcutInfo' puedes pasarle todos los parámetros del shortcut de forma manual: Shortcutmanager.createshortcut("C:\Nuevo link.lnk", etc...)

No me imagino que tipo de problema te puede causar la Class 'ShortcutInfo' porque como ya digo son propiedades y nada más,
si quieres mostrar el código para ver de que forma lo estás utilizando y detallar la excepción/error de compilación o en tiempo de ejecución (si es que hubiera alguna excepción)...

un saludo!
« Última modificación: 16 Febrero 2014, 18:37 pm por Eleкtro » En línea

Car0nte

Desconectado Desconectado

Mensajes: 21


Ver Perfil
Re: Añadir a Favoritos del panel de navegación del explorer
« Respuesta #4 en: 16 Febrero 2014, 18:59 pm »


Me resulta extraño porque el miembro 'ShortcutInfo' sólamente es una Class con propiedades públicas,
en cada propiedad debes especificar los valores del shortcut que quieres crear (aunque algunas de las propiedades como 'IsFile' o 'IsFolder' no importa lo que pongas porque las uso para otros métodos) que luego toma el método 'CreateShortcut', al que le añadí un 'Overload' para poder pasarle un objeto 'ShortcutInfo', pero si te da problemas, en lugar de pasarle un 'ShortcutInfo' puedes pasarle todos los parámetros del shortcut de forma manual: Shortcutmanager.createshortcut("C:\Nuevo link.lnk", etc...)

No me imagino que tipo de problema te puede causar la Class 'ShortcutInfo' porque como ya digo son propiedades y nada más,
si quieres mostrar el código para ver de que forma lo estás utilizando y detallar la excepción/error de compilación o en tiempo de ejecución (si es que hubiera alguna excepción)...

un saludo!

Probablemente el error sea mio. El equipo que uso habitualmente está en en el servicio tecnico. Éste tiene muchos Km y un montón de modificaciones y funciones capadas (por necesidad, experimentos y/o estupidez xD). En cuanto me traigan el otro probaré.

La verdad es que tu método promete .. no había leído nada sobre el tema. En buena parte es mejor mires por donde lo mires porque es algo nativo integrado por completo en NET.

Saludos
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Comparativa Antena Panel Pacific Wireless 19 dBi Contra Antena Panel ABAKS 19 dB
Materiales y equipos
pazienzia 2 10,167 Último mensaje 8 Marzo 2010, 20:09 pm
por pazienzia
quiero hacer un backup de los favoritos de internet explorer
Windows
ENCUENTROSWEB 5 6,053 Último mensaje 11 Enero 2011, 13:30 pm
por simorg
[AYUDA] Panel de navegación fijo.
Desarrollo Web
kodeone 2 2,238 Último mensaje 2 Mayo 2011, 22:06 pm
por kodeone
Cómo añadir notas a tus favoritos en Chrome y Firefox
Noticias
wolfbcn 0 963 Último mensaje 17 Septiembre 2018, 21:31 pm
por wolfbcn
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines