Results 1 to 9 of 9

Thread: Easy Question (how to start an application)

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    Posts
    2
    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.

  2. #2
    Lively Member
    Join Date
    Jul 2000
    Location
    Vaxjo, Sweden
    Posts
    85
    Code:
    Shell "whatever.exe"
    Reality is what you make up when you can't handle your fantasies.

  3. #3
    New Member
    Join Date
    Jul 2000
    Posts
    15

    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?

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    Posts
    2

    thx

    thx @all

  5. #5
    Guest
    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

  6. #6
    Guest
    Likewise, you can use the Shell method to open a file.
    Code:
    Shell "Notepad C:\Windows\Desktop\ttt.txt", vbNormalFocus

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  8. #8
    Guest
    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

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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
  •  



Click Here to Expand Forum to Full Width