473,788 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detecting windows processes.

AaronL
99 New Member
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.ex e" 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 2855
vb5prgrmr
305 Recognized Expert Contributor
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 New Member
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
4061
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 bits of information in the access database. The original application is designed for some poor sod to sit there for hours and manually do the necessary.
2
1501
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 processing that is performed on all orders. To accomplish this, I have created an interface and for the sake of this question, it's only method is called SpecialProcess. For each customer that requires special processing, I create a separate...
5
1727
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 the address space of the process that originally created the shared memory and therefore unavailable to the other processes that may wish to use these instances of the classes. Every so often I forget this and introduce a virtual function causing...
7
8194
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 shut down or restarted. At all other times, the service runs just fine. I need to either detect a logon/logoff event OR check somehow as to whether there is currently a valid logged on user. The closest I have found is ManagementEventWatcher...
0
1383
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 process (since there are 99 processes, I'm trying to keep the screen clutter to a minimum). Basicly, I start the app, then minimize, maximize, show, or hide it based on the option chosen. My problem comes with the actual app I'm monitoring. It...
0
1443
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 processes dies, the app restarts it. One of the options I've written hides the main window of the monitored process (since there are 99 processes, I'm trying to keep the screen clutter to a minimum). Basicly, I start the app, then minimize, maximize,...
2
1316
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 under processes. I know the process is running because the firewall is detecting it. Does anyone have code to list these invisble processes? -Peter
11
1891
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 quite as robust on Windows as it is in other environments. Here's what I'm finding:
13
2861
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. It's most possibly caused by trac and it's dependencies, but several components of the OS where updated, too.
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10118
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2897
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.