Results 1 to 3 of 3

Thread: What should I do when the Shell function doesn't cut it?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    30

    Question

    I have to open up an application that isn't .exe. Therefore the shell command wont work. How else can I open up this application from within my VB program and have it hidden but still keep its focus (like the vbHide constant for the shell function). I remember doing this last year but I dont remember how (brain fart!).

    Thanks for your help in advance,
    Brandr Beekman
    [email protected]

  2. #2
    Guest
    Use the ShellExecute API.

    Code:
    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
    Const SW_SHOW = 5
    Const SW_HIDE = 0
    
    
    Private Sub Command1_Click()
    
        'Open Myfile.txt with it's associated program
        ShellExecute Me.hwnd, "open", "C:\MyFile.txt", "", "C:\Windows\Desktop\", SW_HIDE
    
    End Sub
    Or if you know what program opens it, you can shell it and pass the filename for the command line argument.

    Code:
    Shell "C:\Windows\Notepad C:\MyFile.txt", vbHide

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    30

    Talking Thanks

    Thanks for your help!

    -Brandr

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