1. So, first lets make a new app.
a. Open up Visual BASIC (I use 6 here)
b. Goto File->New Project
c. Click Standard EXE
2. Add a command button
a. Goto the toolbox and click command button
b. Drag a command button out onto the screen
3. Add code to the button
a. Double click on the button. The code window will appear
you will see
Code: Select all
Private Sub Command1_Click()
End Sub
Code: Select all
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
Dim file As String
Code: Select all
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()
End Sub
Code: Select all
file = ".\file.extension"
ShellExecute 0, vbNullString, file, vbNullString, vbNullString, vbNormalFocus
You should now have
Code: Select all
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 cmd1_Click()
file = ".\file.extension"
ShellExecute 0, vbNullString, file, vbNullString, vbNullString, vbNormalFocus
End Sub
4. Build your application
a. Goto File->Make (project name).exe
5. Test
a. Put a file with the same name and extension in the directory with your built app. If you followed directly, it will open with it's default program!
This can also be used for websites and email as seen in the download.
(just give me a minute)
Have fun and feel free to use this code anytime you want.
DOWNLOAD
~HaloKiller