|
-
Jun 23rd, 2001, 05:11 PM
#1
Thread Starter
Member
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
-
Jun 23rd, 2001, 05:27 PM
#2
To open a file with its default App, use the ShellExecute API.
VB 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
Private Sub Command1_Click()
ShellExecute hwnd, "open", "C:\MyFile", "", "", 1
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:
Shell "C:\MyApp C:\MyFile", 1
-
Jun 24th, 2001, 03:32 PM
#3
Thread Starter
Member
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
-
Jun 24th, 2001, 06:10 PM
#4
Double clicked or when it is clicked once.
VB Code:
Private Sub List1_DblClick()
ShellExecute hwnd, "open", List1.List(List1.ListIndex), "", "", 1
'or ShellExecute hwnd, "open", List1.Text, "", "", 1
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|