Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

How to get the Process ID??

Original Message
Name: sthchris
Date: December 2, 2004 at 18:52:12 Pacific
Subject: How to get the Process ID??
OS: Win 2000
CPU/Ram: P42K/256MB
Comment:
Hi everyone,

I am currently working with a VB program, which need to get the Process ID (PID) of the invoking-programs.

For example, when I invoke the winamp.exe, the system will assign a PID for it. And when I invoke the notepad.exe, the system will assign another PID for it in the Tsk Manager. As below:

Task Manager
winamp.exe 2436
notepad.exe 352

My question is, how can i get the PID (using VB6) when everytime i invoke a program (eg. notepad)

Anybody who can assist me on this?

Thanks in advance!


Report Offensive Message For Removal


Response Number 1
Name: Chi Happens
Date: December 3, 2004 at 06:00:20 Pacific
Subject: How to get the Process ID??
Reply: (edit)
you can get the process ids (just like when you press CTRL+SHIFT+ESC) by using Win32 APIs. Its pretty easy...I might even have an example...let me dig around a bit.


Chi


"They mostly come at night...mostly"


Report Offensive Follow Up For Removal

Response Number 2
Name: Chi Happens
Date: December 3, 2004 at 06:21:46 Pacific
Subject: How to get the Process ID??
Reply: (edit)
Ok, you use EnumWindows to get all the active windows running under windows.

Then you call GetWindowText with the handles that EnumWindows provides.

Also, if your application is going to launch the program it is much easier. Use ShellExecute instead of vb's shell and you will have the handle.

In addition you could use CreateProcess and then you could actually have control of the launched app.

Hope this helps
Chi

"They mostly come at night...mostly"


Report Offensive Follow Up For Removal

Response Number 3
Name: sthchris
Date: December 5, 2004 at 17:03:08 Pacific
Subject: How to get the Process ID??
Reply: (edit)
hi Chi,

Can you please send me the coding, if you dont mind.

Thanks in advance!


Report Offensive Follow Up For Removal

Response Number 4
Name: newman
Date: December 7, 2004 at 15:39:16 Pacific
Subject: How to get the Process ID??
Reply: (edit)
Chris,

use the script control in VB and write a short script to get the PID

Set tool = CreateObject("process.id")
'launch notepad
ProcessID = tool.Run("NOTEPAD.EXE")

'the processID for notepad is copied into the variable ProcessID
'you can terminate notepad using the processID'

tool.EndProcess ProcessID

have fun,

newman



Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: How to get the Process ID??

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




acer 312T BIOS problem

K7 Turbo possible max fsb?

Pc anywher problem

WinFLP & OE/Outlook2003

Computer resets after a few minutes


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC