Results 1 to 7 of 7

Thread: Making a Shortcut

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Is there a way to make a shortcut that
    will work on win95 and win98 and winME?

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    This is the best / easiest way to make a shortcut.

    I've tried to make it to work with all windows Operating Systems, but if you can find a bug, I'd be grateful if you could let me know.

    usage :
    • MakeShortcut ModShortcuts.StartMenu & "Help File", App.path & "\HelpFile.doc", app.path
    • MakeShortcut "C:\Path\New shortcut name", "C:\Shortcutted_FileName.exe", "C:\Path"

    Note that you also need a reference (from the project menu in vb) to the :
    Windows Script Host Object Model (Ver 1.0)
    Attached Files Attached Files
    Last edited by alex_read; Apr 5th, 2001 at 03:26 AM.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    I got the following code from vbcode.com. I have not tried it myself. You can try it out.

    Code:
    'NOTE: In Visual Basic 5.0, change Stkit432.dll in the following
    'statement to Vb5stkit.dll.  Stkit432.dll is for Visual Basic 4.0
    
    Private Declare Function fCreateShellLink Lib "STKIT432.DLL" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long
    
    
        Dim lReturn As Long
        
        'Add to Desktop
        lReturn = fCreateShellLink("..\..\Desktop", _
        "Shortcut to Calculator", "c:\windows\calc.exe", "")
        
        'Add to Program Menu Group
        lReturn = fCreateShellLink("", "Shortcut to Calculator", _
        "c:\windows\calc.exe", "")
        
        'Add to Startup Group
        'Note that on Windows NT, the shortcut will not actually appear
        'in the Startup group until your next reboot.
        lReturn = fCreateShellLink("\Startup", "Shortcut to Calculator", _
        "c:\windows\calc.exe", "")
    Also if you are using VB6, I think you may have to change the VB5STKIT.dll to the VB6 version VB6STKIT.dll.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Honeybee, all the examples I read on shortcuts gave
    the Stkit dll example, I could never manage to get this
    to work with vb6 myself

    Oh well


    (ps - please, please put the examples on separate lines : i.e. -

    Private Declare Function fCreateShellLink Lib "STKIT432.DLL" _
    (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, _
    ByVal lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long)


    Sorry for moaning, but it's really helpful , Cheers)!
    Last edited by alex_read; Apr 5th, 2001 at 03:56 AM.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    alex_read, I had copied various code snippets into a text file for my reference, and I posted the above code off that file, without applying my own formatting. I personally don't break lines of code unless they are way too long, and I use my IDE without any toolbox window or property window, so I can take a full view of the code.

    That was an oversight or you can call it negligence. And I think you should keep up 'moaning'

    As for the code, do you mean you could not get it to work even by changing the name of the STKIT file, as suggested in the code??

    As I said earlier, I have not yet tested the code I posted, and intend to use it seriously in our project. So if it is not going to work, I should better start hunting for something better!

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  6. #6
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    It's probably something I was doing I am 99% sure
    that with vb5 it works, and I think I remember getting this to work once.

    But, I also read that changing the file name (and a few other lines) allowed you to use it with vb6.
    I spent around 2-3 hours looking into this, changing the file version & testing, but to no luck.

    After ages of looking at examples, I found the above and have used this ever since to create shortcuts.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517

    Hi...

    Yeah.

    I got it to work. But I dont want to ship
    my program with that DLL (it doesnt come
    with the VB6 Runtime)

    Code:
    Option Explicit
    Option Base 1
    
    ' Urbano DaGama ([email protected])
    
    ' Drop me a line in case you need any help on this program or
    ' if you liked the code. That will encourage me to create more such
    ' programs.
    
    Public Declare Function OSfCreateShellLink Lib "vb6stkit.dll" Alias "fCreateShellLink" _
             (ByVal lpstrFolderName As String, _
             ByVal lpstrLinkName As String, _
             ByVal lpstrLinkPath As String, _
             ByVal lpstrLinkArguments As String, _
             ByVal fPrivate As Long, _
             ByVal sParent As String) As Long
    
    Public Const gstrQUOTE$ = """"
    
    '-----------------------------------------------------------
    ' SUB: CreateShellLink
    '
    ' Creates (or replaces) a link in either Start>Programs or
    ' any of its immediate subfolders in the Windows 95 shell.
    '
    ' IN: [strLinkPath] - full path to the target of the link
    '                     Ex: 'c:\Program Files\My Application\MyApp.exe"
    '     [strLinkArguments] - command-line arguments for the link
    '                     Ex: '-f -c "c:\Program Files\My Application\MyApp.dat" -q'
    '     [strLinkName] - text caption for the link
    '     [fLog] - Whether or not to write to the logfile (default
    '                is true if missing)
    '
    ' OUT:
    '   The link will be created in the folder strGroupName
    '-----------------------------------------------------------
    '
    Public Sub CreateShellLink(ByVal strLinkPath As String, _
             ByVal strGroupName As String, _
             ByVal strLinkArguments As String, _
             ByVal strLinkName As String, _
             ByVal fPrivate As Boolean, _
             sParent As String, _
             Optional ByVal fLog As Boolean = True)
    Dim fSuccess As Boolean
    Dim intMsgRet As Integer
    Dim lREt       As Boolean
       strLinkName = strUnQuoteString(strLinkName)
       strLinkPath = strUnQuoteString(strLinkPath)
       
       If StrPtr(strLinkArguments) = 0 Then strLinkArguments = ""
       
       lREt = OSfCreateShellLink(strGroupName, strLinkName, strLinkPath, strLinkArguments, _
             fPrivate, sParent)    'the path should never be enclosed in double quotes
    
    End Sub
    
    
    Public Function strUnQuoteString(ByVal strQuotedString As String)
    '
    ' This routine tests to see if strQuotedString is wrapped in quotation
    ' marks, and, if so, remove them.
    '
        strQuotedString = Trim$(strQuotedString)
    
        If Mid$(strQuotedString, 1, 1) = gstrQUOTE Then
            If Right$(strQuotedString, 1) = gstrQUOTE Then
                '
                ' It's quoted.  Get rid of the quotes.
                '
                strQuotedString = Mid$(strQuotedString, 2, Len(strQuotedString) - 2)
            End If
        End If
        strUnQuoteString = strQuotedString
    End Function

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