Results 1 to 7 of 7

Thread: Creating shortcuts to the desktop

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    Caracas, Miranda, Venezuela
    Posts
    69

    Post

    How can I create shortcut to the desktop to any program, I have tried with to ways, but they are not work.
    How can I retrieve the \Desktop directory in Windows 95, Nt Workstation, Windows 2000, etc...

    Please Help me

    ------------------


  2. #2
    New Member
    Join Date
    Oct 1999
    Location
    Amersfoort
    Posts
    15

    Post

    Isn't that

    C:\windows\desktop for all OS?

  3. #3
    Guest

    Post

    In Windows NT, there is for any User Profile a Desktop Folder. I think when you would place a LNK File in this Folder it should work.
    C:\WINNT\Profiles\Username\Desktop

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    To get the Desktop folder path, use this:

    Code:
    Private Const CSIDL_DESKTOP = &H0
    Private Const MAX_PATH = 255
    Private Declare Function SHGetSpecialFolderLocation Lib "Shell32" (ByVal hwndOwner As Long, ByVal nFolder As Integer, ppidl As Long) As Long
    Private Declare Function SHGetPathFromIDList Lib "Shell32" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal szPath As String) As Long
    
    Public Function GetDesktopFolderPath(ByVal pHwnd As Long) As String
        Dim lReturn As Long
        Dim lPidl   As Long
        Dim lPath   As Long
        Dim sPath   As String
    
        sPath = Space$(MAX_PATH)
        lReturn = SHGetSpecialFolderLocation(pHwnd, CSIDL_DESKTOP, lPidl)  ' Get lPidl for Id...
        If lReturn = 0 Then                                    ' If success is 0
            lReturn = SHGetPathFromIDList(lPidl, sPath)        '   Get Path from Item Id List
            If lReturn = 1 Then                                '   If success is 1
                sPath = Left(sPath, InStr(sPath, vbNullChar) - 1)             '     Fix path string
                GetDesktopFolderPath = sPath                    '     Return Favorite path
            End If
        End If
    End Function
    Then you can call this function to get the path of the desktop folder:


    Dim strPath As String

    strPath = GetDesktopFolderPath(Me.Hwnd)


    strPath now holds the path to the Desktop.

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    Post

    'create a shortcut to a file and place it on desktop
    '
    Option Explicit
    '
    Private Declare Function SHGetSpecialFolderLocation Lib _
    "Shell32" (ByVal hwndOwner As Long, ByVal nFolder As Integer, _
    ppidl As Long) As Long

    Private Declare Function SHGetPathFromIDList Lib "Shell32" _
    Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal szPath _
    As String) As Long

    Private Const MAX_PATH = 260

    Public Function GetDesktopFolderPath(ByVal pHwnd As Long) _
    As String

    Dim lReturn&
    Dim lPidl&
    Dim strPath$
    strPath$ = Space(MAX_PATH)
    lReturn& = SHGetSpecialFolderLocation(pHwnd, 0, lPidl)

    ' Get lPidl& for this Id...
    If lReturn = 0 Then
    lReturn = SHGetPathFromIDList(lPidl, strPath)
    ' Get Path from Item Id List
    If lReturn = 1 Then 'If successeful
    GetDesktopFolderPath = Left(strPath$, _
    InStr(strPath$, vbNullChar) - 1)

    End If
    End If
    End Function
    '
    '====================put his in form load =======================
    '
    Dim strDesktop$
    strDesktop = GetDesktopFolderPath(Me.hWnd)
    Dim strMyfile$
    strMyfile = InputBox("Enter the path and name of file, & vbcrlf" _
    & "you want to create a shortcut for.")
    Dim strShortCutName$
    strShortCutName$ = InputBox _
    ("Enter the name for the shortcut icon")

    FileCopy strMyfile$, strDesktop$ & "\" & strShortCutName$

  6. #6
    New Member
    Join Date
    Jun 1999
    Posts
    15
    Check out http://www.planet-source-code.com/vb...xtCodeId=7349.
    There is code from the VB6 Pro CD that creates shortcuts. (It is also in a lot easier to download format)

  7. #7
    Member
    Join Date
    Jun 2000
    Location
    Toronto, Canada
    Posts
    52
    Private Const CSIDL_DESKTOP = &H0
    This constant is for the Desktop folder. Do you know the constant for the Startup group?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width