C++ Learning Community Forum
August 01, 2010, 03:25:40 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Hello. Smiley
 
   Home   Help Search Login Register  
Poll
Question: How to list the running application and having controll on it.?  (Voting closed: December 22, 2009, 09:22:42 AM)
1 - 1 (100%)
2 - 0 (0%)
Total Voters: 1

Pages: [1]
  Print  
Author Topic: List Running Application  (Read 274 times)
Renuka
N00b!!1
*
Posts: 1


View Profile
« on: December 15, 2009, 09:22:42 AM »

Hi,
     I want to start implementing Application sharing in JAVA.
As Java does not support windows programming  , so shall i start with using JNI with c++ ?
Tasklist command shows only processes name but not applications running.I got an idea to list the Applications running using c++ then include that in JAVA code  then select the application you want to share then get the dimension of that window then display remotely.

How to list application running using c++?

shall i proceed with this idea?

plz help
Code
GeSHi (cpp):
 
Created by GeSHI 1.0.7.18
Logged
FrozenKnight
ASM Freak
Global Moderator
Dr. of C++ology
*****
Posts: 546


Do it yourself it's the only way to learn.


View Profile
« Reply #1 on: December 17, 2009, 02:52:31 AM »

There are sevral ways to list running processes in windows. (at least 3 i am aware of) so far the easiest i have heard of (and only one i have really used) is to use the Toolhelp32 API.

Before you get started you really need to redefine what you are calling an application, applications have several parts the process, threads and modules. Since the process is the main container for everything else i will assume you are referring it when you say application.

Anyway there are 3 functions you need to pay attention to when you use the ToolHelp32 API CreateToolhelp32Snapshot, Process32First, Process32Next. these functions will allow you to "step" through running processes.

there are other tutorials on the net covering this set of api so i will only give a general idea of how to use them.
first you will need to call CreateToolhelp32Snapshot
save and check the return to see if it's invalid, it's a handle so check it against INVALID_HANDLE_VALUE.
next you use the handle and a PROCESSENTRY32 struct to call Process32First
if Process32First fails the return will be 0 (or false)
Your PROCESSENTRY32 should now contain information on the first process on your system
To get the rest of the processes call Process32Next repeatedly until it returns 0 (or false)

in the future please do not use a poll to post questions like this
« Last Edit: December 17, 2009, 02:56:37 AM by FrozenKnight » Logged


Imagine the impossible, then make it happen.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!