473,385 Members | 1,855 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Detecting windows processes.

AaronL
99
Hello,

Is there an API I can use to detect windows processes? For example, if I were to run notepad.exe, and I wanted to pop a message up in my program that said "notepad.exe" is running? How would I do that?

The real reason I want to do this is because I don't want my program interrupting me if certain programs are running, so if media player is running, I want my program to detect wmplayer.exe or whatever and disable itself.

Thanks!
Oct 25 '09 #1
2 2833
vb5prgrmr
305 Expert 100+
Time to use your friends (yahoo, google, ask, answers, bing) for your needs as there are many examples out there including more than one at PSC (planet-source-code)...



Good Luck
Oct 26 '09 #2
AaronL
99
Umm thanks? Ok to those of you who want to know how to do this, here is a little program I wrote when I found out how to do it.

Expand|Select|Wrap|Line Numbers
  1. Dim WinProcesses() As String
  2. Dim WinProc As Object
  3. Dim WinProcSet As Object
  4. Dim WinProcCount As Long
  5. Dim CheckLoop As Long
  6. Private Sub cmdnotepad_Click()
  7. GetProcesses
  8. For CheckLoop = 1 To WinProcCount
  9.     If WinProcesses(CheckLoop) = "notepad.exe" Then
  10.         MsgBox "Notepad is running!"
  11.         Exit Sub
  12.     End If
  13. Next CheckLoop
  14. MsgBox "Notepad is not running!"
  15. End Sub
  16. Private Sub GetProcesses()
  17. WinProcCount = 0
  18. 'Count the processes to redim the array
  19. Set WinProcSet = GetObject("WinMgmts:").execquery("select * from Win32_process")
  20. For Each WinProc In WinProcSet
  21.     WinProcCount = WinProcCount + 1
  22. Next
  23.  
  24. 'Create the process list in an array
  25. ReDim WinProcesses(1 To WinProcCount) As String
  26. WinProcCount = 0
  27. For Each WinProc In WinProcSet
  28.     WinProcCount = WinProcCount + 1
  29.     WinProcesses(WinProcCount) = WinProc.Name
  30. Next
  31. End Sub
  32.  
If it's possible to check an array for a value without running a processor unfriendly loop, I'd like to know that if you don't mind.
Oct 26 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: bill ramsay | last post by:
Dear all. I am using an existing hodge-podge of an application that runs on top of an Access database. This application dials up customer equipment, handshakes then downloads/uploads various...
2
by: Chris Dunaway | last post by:
I'm writing an app that processes orders for various customers. For most customers, the processing is the same. However, a few customers require custom processing in addition to the standard...
5
by: News Admin | last post by:
I have a bunch of classes, instances of which that need to live in shared memory and be accessed by multiple processes. This means that they cannot have a vtable as the addresses in it will be in...
7
by: Aarti | last post by:
I have written a windows service that needs to perform certain functions only if a User is logged in. The problem I am running into is that I get an error if the computer is in the process of being...
0
by: bamapookie | last post by:
I've written an app that starts and monitors a number of processes. If one of those processes dies, the app restarts it. One of the options I've written hides the main window of the monitored...
0
by: bamapookie | last post by:
I'm sorry if this was posted several times. I did not see my previous post appear after I posted it. I've written an app that starts and monitors a number of processes. If one of those...
2
by: pmclinn | last post by:
I have a couple spyware bots I loaded on a test machine. While I was watching the spyware infect the system I noticed that it was launching a process but it was not listed in my task Managaer...
11
by: BD | last post by:
Hi, all. I'm running 8.2 on Windows. This is a development platform for a project whose production environment is running on a mainframe. I believe that the RI compilation process is not...
13
by: Ilias Lazaridis | last post by:
How to detect memory leaks of python programms, which run in an environment like this: * Suse Linux 9.3 * Apache * mod_python The problem occoured after some updates on the infrastructure....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.