Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Need NT 4.0 EnumProcesses() example

Posted on 1998-06-24
3
516 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

839 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