Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have GoToMyPC but it is not turning off the monitor of the host computer when it connects. Nobody at GoToMyPC has ever heard of this problem and it is not a graphics card driver issue.

Therefore,

I need to write a program that will detect if the following processes are running and then turn off the monitor if they are: g2audioh.exe, g2host.exe, g2mainh.exe, g2printh.exe

I would like the program to autorun at startup.

The following codeproject articles discuss turning on and off a monitor, and detecting running processes (Turn Monitors On and Off from a .NET Console Application[^]Detect if another process is running and bring it to the foreground[^]), but I can't get the code to load into visual studio properly (my inexperience with being the issue). I am more familiar with simple C++ programs written with the Bloodshed compiler.

All advice and input will be appreciated.

Thanks Alot,

Matt
Posted

Here is a nice little project that you can adapt to your needs:
Process viewer[^]

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-Jul-11 13:52pm    
Hm. The project looks nice! The code can be used to understand how it works and to create something else. My 5.
--SA
Espen Harlinn 7-Jul-11 13:53pm    
Thank you, Sergey!
That process viewer is great but I am looking for some tips on building a much simpler program. One without a GUI, command prompt or anything that will interact with the user.

The program I am envisioning is similar to a virus in that it will simply run its processes in the background unseen.

Thanks,

Matt
 
Share this answer
 
Use EnumProcesses()[^] to get the ProcessId list of the currently running programs. (You should do this periodically, every 1, or 5 seconds or something like that if you want a resident program.) And of course you want to get some info about every process to decide if you have to take action or not. To get some info about a process you usually need a handle to the process (not the id). Use OpenProcess()[^] to obtain a handle to a process by its id. Then you can use for example GetModuleFilenameEx()[^] to find out the path of the executable that was used to create that process (pass in NULL as the hModule parameter). You may also want to check out stuff here: PSAPI[^]

And turning the monitor on/off is the same in C/C++ as in the article your found, here is a the article written in C: Turn on/off monitor[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900