Link to home
Start Free TrialLog in
Avatar of Jambyte
JambyteFlag for United States of America

asked on

detecting executing of non vb program

is there a way to have an event when the user runs a program such as IE?
Avatar of DrMaltz
DrMaltz

Jambyte,

Here's a simple solution.. put a timer on a form.. when the timer code executes.. it uses the FindWindow API call to search for a particular application..

VB Declaration:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long

Win32API Definition:
The FindWindow function retrieves the handle of the top-level window whose
class name and window name match the specified strings. This function does
not search child windows.


For example, if I were looking for any notepad apps to start..  My code might look like this..

Private Sub Timer1_Timer()
Dim hwnd As Long

hwnd = FindWindow("Notepad", "")

If hwnd > 0 Then
    MsgBox "I found Notepad"
End If

End Sub


Good Luck,

DrMaltz
Avatar of Jambyte

ASKER

that way wasits to much processing.
ASKER CERTIFIED SOLUTION
Avatar of Toad224
Toad224
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
"System Wide Shell Hook Dll (Version 2.0)"
http://www.freevbcode.com/ShowCode.Asp?ID=1308


If all you want to trap is IE there is a simpler solution
Avatar of DanRollins
Hi Jambyte,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept DrMaltz's comment(s) as an answer.

Jambyte, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer