Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need NT 4.0 EnumProcesses() example

Posted on 1998-06-24
3
Medium Priority
?
524 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 1000 total points
ID: 1464185
0
 

Author Comment

by:swoods
ID: 1464186
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
ID: 1464187
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we 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…
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…
Suggested Courses

772 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