Solved

Need NT 4.0 EnumProcesses() example

Posted on 1998-06-24
3
519 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
[X]
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
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

751 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