How to monitor which programs have been started 
Author Message
 How to monitor which programs have been started

Hi,

In good old DOS I used to have QuickMenu, a program manager which monitored
when and how long a program had been active.

I would like to write a Windows 95 program, which would be active after
Win95 starts up, and which could monitor the following:
- Which program was started? (Complete name)
- When did this happen? (begin time)
- When was the program terminated? (end time)

Maybe there's a Windows API to do this. If you know which one, please e-mail
me (my news-server isn't very reliable).
An example on how to use the API would be appreciated too.

Thanks!

W. van der Berg



Wed, 13 Sep 2000 03:00:00 GMT  
 How to monitor which programs have been started

these question appears every two days. lock in the lates news and you can
find the answer.

gerrit.

Willem van der Berg schrieb in Nachricht

Quote:
>Hi,

>In good old DOS I used to have QuickMenu, a program manager which monitored
>when and how long a program had been active.

>I would like to write a Windows 95 program, which would be active after
>Win95 starts up, and which could monitor the following:
>- Which program was started? (Complete name)
>- When did this happen? (begin time)
>- When was the program terminated? (end time)

>Maybe there's a Windows API to do this. If you know which one, please
e-mail
>me (my news-server isn't very reliable).
>An example on how to use the API would be appreciated too.

>Thanks!

>W. van der Berg



Wed, 13 Sep 2000 03:00:00 GMT  
 How to monitor which programs have been started

   The following code demonstrates how to use a few API functions to gather
information about currently running processes. Perhaps you could use this as
a strating point.


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
' <Picture>
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)

Public Function StripNull(strHasNull As String) As String
Dim iNullPos            As Integer
iNullPos = InStr(strHasNull, Chr$(0))
If iNullPos Then StripNull = Left$(strHasNull, iNullPos - 1)
End Function

Public Function CheckForProcess(strExeName As String) As Long
CheckForProcess = 0
Dim hSnapShot           As Long
Dim uProcess            As PROCESSENTRY32
Dim lProcessHandle      As Long
hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
If hSnapShot > 0 Then
   uProcess.dwSize = Len(uProcess)
   lProcessHandle = ProcessFirst(hSnapShot, uProcess)
   Do While lProcessHandle
      If InStr(UCase(StripNull(uProcess.szExeFile)), _
          UCase(strExeName)) Then
         CheckForProcess = uProcess.th32ProcessID
         Exit Do
      End If
      lProcessHandle = ProcessNext(hSnapShot, uProcess)
   Loop
End If
CloseHandle hSnapShot
End Function



Fri, 15 Sep 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. I am using the Compare MS Project COM Program and having issues

2. How to monitor which programs have been started

3. Problem starting Acces 97 after having started Outlook 2000

4. GUI programmed on 14inch monitor is different on 19inch Monitor

5. Questions I am Having Trouble With

6. I am having problems with addnew

7. I am having trouble with bitblt

8. Help!!I am having VB homework problem...

9. Help: I am having trouble with sendkeys

10. I am having trouble

11. vb5 i am having problems with lost variables

12. I am having probles with this code

 

 
Powered by phpBB® Forum Software