Solved

how  to hide the other exe's when it opens up three more exe with it

Posted on 2004-08-23
5
494 Views
Last Modified: 2010-05-18

hi all ,

i need to open an exe in vb.net inside my form , i was able to do it  using shell or system.dignostics .

The problem i have is that this exe opens up 3 more exe along with it  so when i open the orginal exe inside my form the other 3 exe just opens in the taskbar .

 i  tried to open the other three exe individually in hide mode  even before opening the main exe so that when i open the main exe all other three exe will be in hide mode, but i was able to do just for one  because the other two exe are bind together such that one opens the other one.

please give me some suggestion to tackle this problem

ricky
0
Comment
Question by:BeginnerVB_Net
  • 3
5 Comments
 
LVL 3

Expert Comment

by:Scoobyed
ID: 11878839
http://www.codeproject.com/shell/
u can do allsorts using api like findwindow, to get handle of processes by just their window title, then can sendmessage to them to minimise (some might only minimise to the taskbar, others may not show in taskbar at all)
 
0
 
LVL 3

Accepted Solution

by:
Scoobyed earned 500 total points
ID: 11878867
http://www.vbcity.com/forums/faq.asp?fid=9&cat=Shell&#TID21930

i've used this to set a window to foreground just from it's title (and have used SendMessage WM_CLOSE to close)
http://www.thegamblefamily.net/codelib/

Option Explicit

Private Declare Function PostMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Integer
Private Declare Sub SetWindowText Lib "User" (ByVal hWnd As Integer, ByVal lpString As String)
Private Declare Function GetActiveWindow Lib "User" () As Integer
Private Declare Function WindowFromDC Lib "user32" (ByVal hdc As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long

Const GW_HWNDNEXT = 2
Const SW_NORMAL = 1

Dim MhWnd As Integer

Const WM_CLOSE = &H10
Const GW_HWNDFIRST = &H10

Private Sub cmdGetExtWindows_Click()

  'Call GetWindowTitle(Me, Me.hwnd)

End Sub

Private Sub cmdSetExtFocus_Click()

  'Call GetWindowFromTitle(Me.txtAppTitle.Text)
  Call LookForWindow(Me.txtAppTitle.Text, True)

End Sub

Function GetWindowTitle(frmWindowFrom As Form, lgShellId As Long) As String
   
  Dim lgCurrWnd As Long, lgL As Long, lgLength As Long
  Dim stWindowName As String, inX As Integer
 
  ' Get the hWnd of the first item in the master list
  ' so we can process the task list entries (top-level only)
 
  lgCurrWnd = GetWindow(frmWindowFrom.hWnd, GW_HWNDFIRST)
 
  ' Loop while the hWnd returned by GetWindow is valid
 
  While lgCurrWnd <> 0
   
    GetWindowThreadProcessId lgCurrWnd, lgL&
    If lgL& = lgShellId Then
 
      ' Get the length of task name identified by CurrWnd in the list
      lgLength = GetWindowTextLength(lgCurrWnd)
     
      ' Get task name of the task in the master list
      stWindowName = Space$(lgLength + 1)
      lgLength = GetWindowText(lgCurrWnd, stWindowName, lgLength + 1)
     
      ' If there is a task name in the list, add the item to the list
     
      If lgLength > 0 Then
        GetWindowTitle = stWindowName
        Exit Function
      End If
    End If
   
    ' Get the next task list item in the master list
    lgCurrWnd = GetWindow(lgCurrWnd, GW_HWNDNEXT)
 
    ' Process Windows events
    inX = DoEvents()
  Wend
 
End Function

Function GetWindowFromTitle(ByVal strTitle As String)

  Dim retval As Long
  Dim retval2 As Long
 
  retval = FindWindow("XLMAIN", 0&)
 
  If retval <> 0 Then
    retval2 = ShowWindow(retval, SW_NORMAL)
    retval2 = SetForegroundWindow(retval)
  Else
    MsgBox strTitle & " is not running"
  End If

End Function

Function LookForWindow(ByVal strAppName As String, ByVal blnActivateWindow As Boolean) As Boolean

  Dim hWnd As Long
  Dim strWinTitle As String
  Dim varRet As Long
  Dim retval2 As Long
 
  LookForWindow = False
  strAppName = UCase$(strAppName)
  hWnd = FindWindow(0&, 0&)
 
  Do Until hWnd = 0
    If GetParent(hWnd) = 0 Then
      strWinTitle = Space$(255)
      varRet = GetWindowText(hWnd, strWinTitle, Len(strWinTitle))
      If varRet Then
        strWinTitle = Left$(strWinTitle, varRet)
        strWinTitle = UCase$(strWinTitle)
        If InStr(strWinTitle, strAppName) = 1 Then
          LookForWindow = True
         
          If blnActivateWindow Then
            retval2 = ShowWindow(hWnd, SW_NORMAL)
            retval2 = SetForegroundWindow(hWnd)
          End If
         
          Exit Do
        End If
      End If
    End If
    hWnd = GetWindow(hWnd, GW_HWNDNEXT)
  Loop

End Function
0
 
LVL 3

Expert Comment

by:Scoobyed
ID: 11878900
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now