-
Feb 3rd, 2017, 02:05 PM
#1
Thread Starter
PowerPoster
start exe from command button
possible to launch a .exe in eventclikc of commandbutton1?
Note:
Exe is a simple vb6 compiled program.
Is in c:\mydir\myexe.exe
-
Feb 3rd, 2017, 02:18 PM
#2
Re: start exe from command button
Shell command?
Or, in more complex cases ShellExecute API call?
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Feb 3rd, 2017, 03:22 PM
#3
Thread Starter
PowerPoster
Re: start exe from command button
Originally Posted by Elroy
Shell command?
Or, in more complex cases ShellExecute API call?
... ShellExecute API call?
hummmm
Not experince.
Simple code, plaase.
Tks.
-
Feb 3rd, 2017, 03:46 PM
#4
Re: start exe from command button
-
Feb 3rd, 2017, 03:46 PM
#5
Re: start exe from command button
The VB6 built-in "Shell" function may do what you need. However, here's the ShellExecute API ...
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_SHOWMAXIMIZED = 3
Private Const SW_SHOWNORMAL = 1
'
Private Sub Command1_Click()
Dim rtn As Long
'
Dim sFileSpec As String
sFileSpec = "Notepad.exe"
rtn = ShellExecute(0, "Open", sFileSpec, vbNullString, vbNullString, SW_SHOWNORMAL)
End Sub
I just set it up to execute Notepad. However, ShellExecute will also work with file associations. In other words, you could send it a "Something.Docx" file and it'd open it with Word.
Enjoy,
Elroy
EDIT1: For info on Shell, just type in Shell somewhere in your code, and then hit F1 (assuming you have the MSDN installed).
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
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
|