Solved

Running Processes Info

Posted on 1999-01-27
2
159 Views
Last Modified: 2012-05-04
I need to check the list of Running Processes every so often and if multiple outlook processes exist, I need to clear them.

Here is a snipplet of the code I am using:

Public Declare Function CreateToolhelpSnapshot Lib "Kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long

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

The only data I get returned id szExeFile (ProcessName)

How can I get the UniqueID for the thread or process so that I can terminate that process?
0
Comment
Question by:blevan
2 Comments
 
LVL 1

Accepted Solution

by:
mukvij earned 100 total points
ID: 1470942
1. If you know caption of window, You can use FindWindow API to return you with Process Id. Then You can you this handle in OpenProcess to get actual process handle.

2. If you Shelled Outlook use Shell as a function to return you peocess Id.



0
 

Author Comment

by:blevan
ID: 1470943
This is required because I am Shelling Outlook to get a unique ID then when I close Outlook, I AppActivate Unique ID and SendKeys Alt-F4 until the AppActivate causes an error condition (this way I close and dialog boxes which may have popped-up i.e. New Mail Notification.). Outlook is disappearing from the Task List but on occasion it remains in the running processes list, this builds-up until the system is finally choked (no avail resources). I can get a list of the processes running but I need a way to address them to close them or end their task.

I will try mukvij's suggestion and see if I can address the processes using find window although I though the program has to show in the Task list (Alt-Tab or Taskbar) not the Running Processes List (Crtl-Alt-Delete). If it works, I'll accept mukvij's solution.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

932 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

18 Experts available now in Live!

Get 1:1 Help Now