Detecting a programming running 
Author Message
 Detecting a programming running

Hi,

Yea, yea, yea.  I know.  There was a thread on these groups a little
while back but I totally missed them.  Here is my problem.  I need to
determine if a particular windows program is running or not.  Now, I
just know the full pathname to the program.  I need to do this inside a
VB4 program to limit the number of invocation of these programs to 1.
Can anyone help?

--

Regards

Vitus Lee



Fri, 01 Sep 2000 03:00:00 GMT  
 Detecting a programming running

do you know the title caption of the main form of the program, or does it even have one?

Quote:

>Hi,

>Yea, yea, yea.  I know.  There was a thread on these groups a little
>while back but I totally missed them.  Here is my problem.  I need to
>determine if a particular windows program is running or not.  Now, I
>just know the full pathname to the program.  I need to do this inside a
>VB4 program to limit the number of invocation of these programs to 1.
>Can anyone help?

>--

>Regards

>Vitus Lee

  Gofreddo.vcf
< 1K Download


Sat, 02 Sep 2000 03:00:00 GMT  
 Detecting a programming running

Hi,

I'm sorry if something's wrong here. (am from MS-Access newsgroups and still
learning VB)

Here's something that works fairly well in Access 97 & 95. (call the
fEnumWindows function)

Private Declare Function apiGetClassName Lib "User32" Alias _
                "GetClassNameA" (ByVal Hwnd As Long, _
                ByVal lpClassname As String, _
                ByVal nMaxCount As Long) As Long
Private Declare Function apiGetDesktopWindow Lib "User32" Alias _
                "GetDesktopWindow" () As Long
Private Declare Function apiGetWindow Lib "User32" Alias _
                "GetWindow" (ByVal Hwnd As Long, _
                ByVal wCmd As Long) As Long
Private Declare Function apiGetWindowLong Lib "User32" Alias _
                "GetWindowLongA" (ByVal Hwnd As Long, ByVal _
                nIndex As Long) As Long
Private Declare Function apiGetWindowText Lib "User32" Alias _
                "GetWindowTextA" (ByVal Hwnd As Long, ByVal _
                lpString As String, ByVal aint As Long) As Long
Private Const mcGWCHILD = 5
Private Const mcGWHWNDNEXT = 2
Private Const mcGWLSTYLE = (-16)
Private Const mcWSVISIBLE = &H10000000
Private Const mconMAXLEN = 255

Function fEnumWindows()
Dim lngX As Long, lngLen As Long
Dim lngStyle As Long, strCaption As String

    lngX = apiGetDesktopWindow()
    'Return the first child to Desktop
    lngX = apiGetWindow(lngX, mcGWCHILD)

    Do While Not lngX = 0
        strCaption = fGetCaption(lngX)
        If Len(strCaption) > 0 Then
            lngStyle = apiGetWindowLong(lngX, mcGWLSTYLE)
            'enum visible windows only
            If lngStyle And mcWSVISIBLE Then
                Debug.Print "Class = " & fGetClassName(lngX),
                Debug.Print "Caption = " & fGetCaption(lngX)
            End If
        End If
        lngX = apiGetWindow(lngX, mcGWHWNDNEXT)
    Loop
End Function
Private Function fGetClassName(Hwnd As Long)
    Dim strBuffer As String
    Dim intCount As Integer

    strBuffer = String$(mconMAXLEN - 1, 0)
    intCount = apiGetClassName(Hwnd, strBuffer, mconMAXLEN)
    If intCount > 0 Then
        fGetClassName = Left$(strBuffer, intCount)
    End If
End Function

Private Function fGetCaption(Hwnd As Long)
    Dim strBuffer As String
    Dim intCount As Integer

    strBuffer = String$(mconMAXLEN - 1, 0)
    intCount = apiGetWindowText(Hwnd, strBuffer, mconMAXLEN)
    If intCount > 0 Then
        fGetCaption = Left$(strBuffer, intCount)
    End If
End Function

--
Please limit questions to newsgroups only...
Just my $.001
Dev Ashish
---------------
The Access Web ( http://home.att.net/~dashish )
---------------

do you know the title caption of the main form of the program, or does it
even have one?

Quote:

>Hi,

>Yea, yea, yea.  I know.  There was a thread on these groups a little
>while back but I totally missed them.  Here is my problem.  I need to
>determine if a particular windows program is running or not.  Now, I
>just know the full pathname to the program.  I need to do this inside a
>VB4 program to limit the number of invocation of these programs to 1.
>Can anyone help?

>--

>Regards

>Vitus Lee



Sat, 02 Sep 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Detecting a programming running

2. Help needed detecting if a program is running

3. Two parter: Detect app already running, then pass command args to original program

4. Detecting if a program is already running

5. Detect, a program is running

6. How to detect running program?

7. HELP: Detecting whether an External Program is running.

8. detecting if a program is already running

9. Detect if a program is running w/o FindWindow

10. detect words on running programs

11. How to detect and kill a running program?

12. Detecting/closing a running program

 

 
Powered by phpBB® Forum Software