Solved

Need NT 4.0 EnumProcesses() example

Posted on 1998-06-24
3
509 Views
Last Modified: 2008-02-01
I am trying to kill a "hung" application process in NT.  This process is an ActiveX .EXE so it runs independently.  As this process does not have a GUI, I am trying to check to see if it is running and if so, get its process ID using the PSAPI.DLL functions.  I think I have the PSAPI.DLL file itself, but I need an example of how to use this DLL to check for a running process and how to get the process ID.

Thanks,

Shawn Woods
0
Comment
Question by:swoods
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
clifABB earned 250 total points
Comment Utility
0
 

Author Comment

by:swoods
Comment Utility
clifABB,

Your answer was perfect!  I spent 3 days searching for an example or any documentation without luck before this Knowledgebase article.  Thanks a million!!!  

I'm going to give you the "A" credit anyway for solving my problem so quickly, but I have a small related question for you if you don't mind.  Now that I have the Path and other Process Information, what is the best way to kill the "hung" process(es)?

Thanks again for your help!

Shawn Woods
0
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
This is what I have learned:

Apparently you can end a process by calling ExitProcess().  To call this, you must pass an ExitCode which is retrieved with GetExitCodeProcess()
From what I gather, the following code will kill the process specified:

Declare Sub ExitProcess Lib "kernel32" Alias "ExitProcess" (ByVal uExitCode As Long)
Declare Function GetExitCodeProcess Lib "kernel32" Alias "GetExitCodeProcess" (ByVal hProcess As Long, lpExitCode As Long) As Long
Public Sub KillProcess(lProcess As Long)
  Dim lExitCode As Long
  Dim lRes As Long

  lRes = GetExitCodeProcess(lProcess, lExitCode)
  ExitProcess lExitCode
End Sub

I'm not sure if this will work, but it seems like it should.

For more information on processes, check out the info at MSDNOnline:
http://premium.microsoft.com/msdn/library/sdkdoc/prothred_7mib.htm
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

763 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

7 Experts available now in Live!

Get 1:1 Help Now