Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows
Visual Basic > Code Snippets sample source codes
Launch a file with associated program
Launch a file with associated program 'This example will show you how to launch a file with his associate program. 'In the example below test.mp3 would open with Winamp #If Win32 Then 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 Declare Function GetDesktopWindow Lib "user32" () As Long #Else Declare Function ShellExecute Lib "SHELL" (ByVal hwnd%, _ ByVal lpszOp$, ByVal lpszFile$, ByVal lpszParams$, _ ByVal lpszDir$, ByVal fsShowCmd%) As Integer Declare Function GetDesktopWindow Lib "USER" () As Integer #End If Public Const SW_SHOWNORMAL = 1 'Insert this code to your form: Function StartDoc(DocName As String) As Long Dim Scr_hDC As Long Scr_hDC = GetDesktopWindow() StartDoc = ShellExecute(Scr_hDC, "Open", "c:\test.mp3", "", "C:\", SW_SHOWNORMAL) End Function
Privacy Policy
|
Link to Us
|
Links