|
-
Aug 11th, 2000, 04:04 AM
#1
Thread Starter
New Member
Hi there,
I' ve searched several documentation but I wasn't able to find solutions.
How could I start a program from my VB-app.
-
Aug 11th, 2000, 04:14 AM
#2
Lively Member
Code:
Shell "whatever.exe"
Reality is what you make up when you can't handle your fantasies.
-
Aug 11th, 2000, 04:15 AM
#3
New Member
here
use the shell command
e.g
Code:
Shell "C:\MYPROG.EXE"
You can also chose how the application is displayed when it is started.
The following constants can be used for this.
vbHide --- Window is hidden and focus is passed to the hidden window.
vbNormalFocus --- Window has focus and is restored to its original size and position.
vbMinimizedFocus --- Window is displayed as an icon with focus.
vbMaximizedFocus --- Window is maximized with focus.
vbNormalNoFocus --- Window is restored to its most recent size and position. The currently active window remains active.
vbMinimizedNoFocus --- Window is displayed as an icon. The currently active window remains active.
If you want to use this aswell, the command would be as follows
Code:
Shell ("C:\MYPROG.EXE", vbMaximizedFocus)
Hope this helps
If practice makes perfect...
and nobody's perfect...
why the hell practice?
-
Aug 11th, 2000, 04:45 AM
#4
Thread Starter
New Member
-
Aug 13th, 2000, 12:55 AM
#5
The Shell function will basically load any exe, but not any other files. Instead, you should use the ShellExecute function.
Code:
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
Public Const SW_SHOWNORMAL = 1
Public Const SW_ShowMinimized = 2
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_Hide = 0
Public Const SW_MAX = 10
Public Const SW_MAXIMIZE = 3
Public Const SW_MINIMIZE = 6
Public Const SW_NORMAL = 1
ShellExecute Me.hwnd, vbNullString, "C:\txtfile.txt", vbNullString, "c:\", SW_SHOWNORMAL
-
Aug 13th, 2000, 08:40 AM
#6
Likewise, you can use the Shell method to open a file.
Code:
Shell "Notepad C:\Windows\Desktop\ttt.txt", vbNormalFocus
-
Aug 13th, 2000, 09:13 AM
#7
Monday Morning Lunatic
If you're sure that the application exists.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 13th, 2000, 12:52 PM
#8
It's very easy to tell if an application exists:
Code:
ffile = Dir("C:\file.exe")
'returns "" if file doesn't exist
'returns "C:\file.exe" if file does exist
If Not ffile = "" Then
'Shell the program
Else
Msgbox "File doesn't exist!", 16
End If
-
Aug 13th, 2000, 05:02 PM
#9
Monday Morning Lunatic
I think your first code was probably better, because it uses Windows' own associations to open the file.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
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
|