Results 1 to 3 of 3

Thread: open any type of file with its associated widows program

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Location
    Canberra - Australia
    Posts
    8

    Question

    Hi there
    I'm not terribly advanced in vb, but I've looked through all the help files, and articles, for an answer which I'm sure is very simple.

    I simply want to be able to press a command button, which will trigger a file (e.g. "c:\media\mysong.mp3"), to be opened with by its associated application (e.g. "Media Player"). just as what would happen if I went to the file in windows explorer, and double clicked it.

    can somebody please come to my rescue.
    *Waco_Jaco*

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Code:
    Option Explicit
    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
    Private Const SW_SHOWNORMAL = 1
    
    Private Sub Command1_Click()
    Dim retVal As Long
        retVal = ShellExecute(Me.hwnd, "open", "c:\media\mysong.mp3", vbNullString, vbNullString, SW_SHOWNORMAL)
    End Sub

  3. #3
    taLON
    Guest
    take a look at http://www.vbsquare.com/tips/tip236.html

    greets

    taLON

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