Results 1 to 7 of 7

Thread: Shell ||-- Need Help!!! --||

  1. #1

    Thread Starter
    Hyperactive Member mastermind94's Avatar
    Join Date
    Jun 2000
    Location
    Montréal, Canada
    Posts
    441

    Unhappy

    Hi! I used these codes http://www.vb-world.net/tips/tip5.html to know when an application with the shell command is finish but, how do I hide the window? I know with the shell command, you add ", VbHide" but I do not see any shell command. Do you guys have an idea?




  2. #2
    Member
    Join Date
    May 2000
    Posts
    41
    Hide what window? The call itself doesnt generate a window.
    If you are talking about the form you used it with then just do a form1.visible = false.

    hope this helps
    Here I doeh again

  3. #3

    Thread Starter
    Hyperactive Member mastermind94's Avatar
    Join Date
    Jun 2000
    Location
    Montréal, Canada
    Posts
    441

    Arrow !

    I tried out this code and it produce a window! I try to execute a DOS program!

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Code:
    Private Const STARTF_USESHOWWINDOW = &H1
    Public Enum enSW
    SW_HIDE = 0
    SW_NORMAL = 1
    SW_MAXIMIZE = 3
    SW_MINIMIZE = 6
    End Enum
    
    
    Private Type STARTUPINFO
        cb As Long
        lpReserved As String
        lpDesktop As String
        lpTitle As String
        dwX As Long
        dwY As Long
        dwXSize As Long
        dwYSize As Long
        dwXCountChars As Long
        dwYCountChars As Long
        dwFillAttribute As Long
        dwFlags As Long
        wShowWindow As Integer
        cbReserved2 As Integer
        lpReserved2 As Long
        hStdInput As Long
        hStdOutput As Long
        hStdError As Long
    End Type
    
    Private Type PROCESS_INFORMATION
        hProcess As Long
        hThread As Long
        dwProcessID As Long
        dwThreadID As Long
    End Type
    
    Private Declare Function WaitForSingleObject Lib _
    "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds _
    As Long) As Long
    
    Private Declare Function CreateProcessA Lib "kernel32" _
    (ByVal lpApplicationName As Long, ByVal lpCommandLine As _
    String, ByVal lpProcessAttributes As Long, ByVal _
    lpThreadAttributes As Long, ByVal bInheritHandles As Long, _
    ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, _
    ByVal lpCurrentDirectory As Long, lpStartupInfo As _
    STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) _
    As Long
    
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject _
    As Long) As Long
    
    Private Const NORMAL_PRIORITY_CLASS = &H20&
    Private Const INFINITE = -1&
    
    
    
    Public Sub ExecCmd(cmdline$)
    Dim proc As PROCESS_INFORMATION
    Dim start As STARTUPINFO
    
    'Initialize the STARTUPINFO structure:
    start.cb = Len(start)
    start.dwFlags = STARTF_USESHOWWINDOW
    start.wShowWindow = SW_HIDE
    
    'Start the shelled application:
    ret& = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, _
    NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
    
    'Wait for the shelled application to finish:
    ret& = WaitForSingleObject(proc.hProcess, INFINITE)
    ret& = CloseHandle(proc.hProcess)
    End Sub
    
    
    
    Private Sub Form_Load()
    ExecCmd "Notepad.exe"
    End Sub
    But I don't recommend shelling it Hidden, because you can only end it with CTRL+ALT+DELETE, and your prog won't continue until it's closed!
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5
    Member
    Join Date
    May 2000
    Posts
    41
    that's not true. If he uses the 'command.com /c' before it (or 'cmd.exe /c' in NT) then it will close the dos box when it's finished.

    e.g.:
    c:\command.com /c c:\windows\pbrush.exe



    that line will load paintbrush and close the dos textbox right after it does so.

    hope this helps
    Here I doeh again

  6. #6
    Lively Member
    Join Date
    Jul 1999
    Posts
    77

    Question Isn't there a flag???

    I might sound like a newbie but isn't there a flag, such as,
    Shell "C:\Windows\Explorer.exe" , 1
    or some number like that?
    I would check for u but I'm in highschool <

    -Justin

  7. #7
    Member
    Join Date
    May 2000
    Posts
    41
    justin,
    it's not the shell command he(or she) is trying to use but a function that does the same thing except it can detect when the program it calls ends. Otherwise, yes the Shell command does have a flag for that.
    Here I doeh again

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