Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell

Status
Not open for further replies.

rraney

Programmer
May 18, 2000
11
US
Hello,

I have a menu to shell some common tools.
If I Shell Calc, to put a calculator on the screen, and then minimize it, how do I check to see if it is running if I go to Shell it again. If one calculator is running in the background I do not want to start another, just maximixe the one that is already running.

Thanks
Raney
 
This should do it for you:
Code:
Option Explicit

Declare Function FindWindow Lib "user32" _
        Alias "FindWindowA" _
        (ByVal lpClassName As String, _
        ByVal lpWindowName As String) As Long

Declare Function ShowWindow Lib "user32" _
        (ByVal hWnd As Long, _
        ByVal nCmdShow As Long) As Long

Public Sub StartCalculator()
    Dim hWnd As Long
    Dim retVal
    
    hWnd = FindWindow(vbNullString, "Calculator")
    If hWnd <> 0 Then
        ShowWindow hWnd, vbNormalFocus
    Else
        retVal = Shell(&quot;C:\WINNT\System32\CALC.EXE&quot;, 1)
    End If
End Sub
 
Thanks dsi,

This looks like it will do exactly what I am looking for.

Raney
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top