Solved

Listening to the user running applications

Posted on 2000-04-03
18
183 Views
Last Modified: 2012-05-04
Hi all
I have a small project installed in each workstations that saved the user name ,date and time of login to the Network to a database.
I need to add another task to this project that's all the applications that the user runs them during his session with the time.
For example :
Suppose the user click on the (Microsoft word) then the system will add the following :
Application name, and the time to the database.

Is it possible to do so please advice or give me any other idea to perform this task.

Zr
0
Comment
Question by:zrikat
  • 8
  • 7
  • 3
18 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2679152
http://codeguru.developer.com/vb/articles/1968.shtml

this will display all running programs
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2679155
sorry not what youre looking for is it, you will probably need to use subclassing
0
 

Author Comment

by:zrikat
ID: 2679160
Edited text of question.
0
 

Author Comment

by:zrikat
ID: 2679179
Thank you Azr
but this only display the active pplications which I can display them.
what I want exactly is to Listen to the user when he run an application automaticly add it to the DB.


0
 

Author Comment

by:zrikat
ID: 2679197
Thank you Azr
but this only display the active pplications which I can display them.
what I want exactly is to Listen to the user when he run an application automaticly add it to the DB.


0
 
LVL 1

Expert Comment

by:Maximka
ID: 2679217
Read MSDN about Hooks . You can via Hook to catch message that user sends by his clicking on each object and at this moment to check if List of tasks was udated by new task .Then You will know that the task was added or removed and You can to update Your database with the Time when it happened.
It is not most simple way , but it will work 100 %.
Hope this will help You.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2679263
i said subclassing earlier, i meant hooks
0
 

Author Comment

by:zrikat
ID: 2679275
Is there any example or code that I can follow it to understand who the Hook work???
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2679283
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 28

Expert Comment

by:AzraSound
ID: 2679292
http://blackbeltvb.com/

theres an example on hooking there called MHHook but you can only download it if youre a subscriber, whatever that means
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2679302
0
 
LVL 1

Expert Comment

by:Maximka
ID: 2679370
Sorry, AzraSound I didn't mean to argue You , I just described him what exactly the Key word that will help him for searching in MSDN. That's all.
Sorry.
0
 

Author Comment

by:zrikat
ID: 2679398
Is there any other way ?
the Hook is very difficult to understand?



0
 
LVL 1

Expert Comment

by:Maximka
ID: 2679445
Yes, You can work with timer and GetMessage , but it will catch performance percantage of your CPU.
0
 

Author Comment

by:zrikat
ID: 2679541
Max
Let me try it ?
would you please provide me with the code or the steps.


0
 
LVL 28

Accepted Solution

by:
AzraSound earned 200 total points
ID: 2682993
zrikat, i created a small project using a timer to continuously check for running windows and display a msgbox when a new one arises. Some considerations before trying this out, I set the timer to 5 seconds, again I dont know what kind of stall this will cause on performance nor do i know the effects on memory. You may wish to monitor these when this runs. Also, you will notice i declare the array arrWindows(20) which specifies the number of elements to hold. If you feel that more processes than this can be runing at one time, please increase it accordingly.  Another note, I use Windows 98 and VB 6.0  SP3.  I have no idea what kind of conflicts or discompatibility there might be with other platforms. Please let me know how it works and I will try to adjust it accordingly.  Now for the code, it requires a module and one form with a timer control and a listbox and a command button. Upon loading the form, all running processes are listed. After pressing the command button, al running processes will be compared to the previous instance to see if a new program was begun.

In the module:

Option Explicit


Public Const TH32CS_SNAPPROCESS As Long = 2&
Public Const MAX_PATH As Integer = 260
Public Type PROCESSENTRY32
    dwSize As Long
    cntUsage As Long
    th32ProcessID As Long
    th32DefaultHeapID As Long
    th32ModuleID As Long
    cntThreads As Long
    th32ParentProcessID As Long
    pcPriClassBase As Long
    dwFlags As Long
    szExeFile As String * MAX_PATH
End Type
Public Declare Function CreateToolhelpSnapshot Lib "Kernel32" _
    Alias "CreateToolhelp32Snapshot" _
    (ByVal lFlags As Long, ByVal lProcessID As Long) As Long

Public Declare Function ProcessFirst Lib "Kernel32" _
    Alias "Process32First" _
    (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long

Public Declare Function ProcessNext Lib "Kernel32" _
    Alias "Process32Next" _
    (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long

Public Declare Sub CloseHandle Lib "Kernel32" _
    (ByVal hPass As Long)




On the Form:

Option Explicit
Dim arrWindows(20) As Variant
Dim i As Integer

Private Sub Command1_Click()
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    Dim hSnapShot As Long
    Dim uProcess As PROCESSENTRY32
    Dim r As Long
    Dim j As Integer
    List1.Clear
    hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
    If hSnapShot = 0 Then
        Exit Sub
    End If
    uProcess.dwSize = Len(uProcess)
    r = ProcessFirst(hSnapShot, uProcess)
    Do While r
        For i = 0 To UBound(arrWindows)
            If uProcess.szExeFile = arrWindows(i) Then
                Exit For
            Else
                If i = UBound(arrWindows) Then _
                    MsgBox Now & vbCrLf & "Program: " & _
                        uProcess.szExeFile, vbInformation, _
                        "New Program Started"
            End If
        Next
        List1.AddItem uProcess.szExeFile
        arrWindows(j) = uProcess.szExeFile
        j = j + 1
        r = ProcessNext(hSnapShot, uProcess)
    Loop
    Do
    arrWindows(j) = ""
    j = j + 1
    Loop Until j = UBound(arrWindows)
    Call CloseHandle(hSnapShot)
End Sub


Private Sub Form_Load()
    Dim hSnapShot As Long
    Dim j As Integer
    Dim uProcess As PROCESSENTRY32
    Dim r As Long
    Timer1.Enabled = False
    hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
    If hSnapShot = 0 Then
        Exit Sub
    End If
    uProcess.dwSize = Len(uProcess)
    r = ProcessFirst(hSnapShot, uProcess)
    Do While r
        List1.AddItem uProcess.szExeFile
        arrWindows(j) = uProcess.szExeFile
        j = j + 1
        r = ProcessNext(hSnapShot, uProcess)
    Loop
    Call CloseHandle(hSnapShot)
End Sub


0
 

Author Comment

by:zrikat
ID: 2683080
Dear AzraSound

I appreciate your help really you are very respected man thank you very much.

Please have a look at :
http://www1.experts-exchange.com/Computers/Programming/Windows/Visual_Basic/Q_10321906.html

Zr
0
 

Author Comment

by:zrikat
ID: 2683092
It's working excellent without any conflicts on memory or the computer it self.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 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

10 Experts available now in Live!

Get 1:1 Help Now