Results 1 to 4 of 4

Thread: Opening files from VB

  1. #1

    Thread Starter
    Member
    Join Date
    May 2001
    Posts
    39

    Opening files from VB

    I am having a bit of a problem.
    I was wondering how one could use a VB program to open files of different types. General? I know.
    More specifically, I was wanting to present different files to the user within a VB form and allow them to open each when the user clicks them.
    Say the user clicks an MP3 file. Can I make it then run that file in the default mp3 player? Or any other sort of file.

    Thanks in advance all.
    Linux r00lz, stay in sk00l
    ô¿ô

    Guitar Playn' Computor Programmin' Girl Repeller = Me

    Dim Thinking As String
    Thinking = Thought As VB opens First Time

    Thinking = HUH!?

    If I Manage A Decent Salary In Programming I'll Be Happy

    I Don't Think I'm Gonna Die Happy

  2. #2
    Megatron
    Guest
    To open a file with its default App, use the ShellExecute API.
    VB Code:
    1. 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
    2.  
    3. Private Sub Command1_Click()
    4.    
    5.     ShellExecute hwnd, "open", "C:\MyFile", "", "", 1
    6.    
    7. End Sub

    To open a file in a specific App, use VB's Shell method, and pass the filename as the command line argument.
    VB Code:
    1. Shell "C:\MyApp C:\MyFile", 1

  3. #3

    Thread Starter
    Member
    Join Date
    May 2001
    Posts
    39
    let me know if i'm becoming a nuacance again, but how would you get the path of a file in a file list box in th the

    ShellExecute hwnd, "open", "C:\MyFile", "", "", 1

    when the item in the listbox is double clicked?
    ô¿ô

    Guitar Playn' Computor Programmin' Girl Repeller = Me

    Dim Thinking As String
    Thinking = Thought As VB opens First Time

    Thinking = HUH!?

    If I Manage A Decent Salary In Programming I'll Be Happy

    I Don't Think I'm Gonna Die Happy

  4. #4
    Matthew Gates
    Guest
    Double clicked or when it is clicked once.


    VB Code:
    1. Private Sub List1_DblClick()
    2.     ShellExecute hwnd, "open", List1.List(List1.ListIndex), "", "", 1
    3.   'or ShellExecute hwnd, "open", List1.Text, "", "", 1
    4. End Sub

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