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

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

hi all ,

i need to open an exe in 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

Question by:BeginnerVB_Net
  • 3

Expert Comment

ID: 11878839
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)

Accepted Solution

Scoobyed earned 500 total points
ID: 11878867

i've used this to set a window to foreground just from it's title (and have used SendMessage WM_CLOSE to close)

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 SW_NORMAL = 1

Dim MhWnd As Integer

Const WM_CLOSE = &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()
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)
    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)

End Function

Expert Comment

ID: 11878900

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity Facial recognition software (time and attendance) 6 39
I need help converting a bitmap to an image in VB.Net 1 32
VB.Net - KeyPress Event 4 36
VB.NET 1 22
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

772 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