CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2002
    Location
    Belgium
    Posts
    125

    Executing a shortcut

    How can I execute a shortcut? I tried it whit shell but i get error n 5 ? Please help me
    Bert Willekens,

  2. #2
    Join Date
    Sep 2001
    Location
    IL, USA
    Posts
    1,090
    Code:
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Const SW_SHOWNORMAL = 1
    
    Private Sub Command1_Click()
        ShellExecute Me.hwnd, "Open", "C:\Windows\Desktop\Outlook Express.lnk", vbNullString, "", SW_SHOWNORMAL
    End Sub

  3. #3
    Join Date
    Dec 2001
    Posts
    6,332
    MKSa's answer will only work with certain system settings, not to mention a specific desktop icon. Here is the way to use whatever the default browser happens to be.

    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


    URL = "http://www.codeguru.com/"
    ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

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

Featured