Go Back   TechArena Community > Software > Windows Software
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 27-06-2011
Member
 
Join Date: Sep 2010
Posts: 65
How to get application process ID for ms-word application.

Hi, I used to do lot of work on the Microsoft word application where I come up with process id. I want to know my process id for my Microsoft word application. The MS-Word applications are identify upon by my some other application except my visual c application when I try to use it in the same machine. Does anyone what may be the reason of this problem and how to persist it as I had tried many things but not anything had help me out.
Reply With Quote
  #2  
Old 27-06-2011
Member
 
Join Date: Apr 2009
Posts: 484
Re: How to get application process ID for ms-word application.

I don?t know much about it and had a made a bit search regarding your problem but dint come up with much things. You should try to use the toolhlp library in that use CreateToolhelp32Snapshot(...) and then try Process32First(...) and then Process32Next(...). You should even try few sample code which is given in the MSDN which id under the CreateToolHelp32Snapshot API help. Hope this will help you to get clear from tour problem.
Reply With Quote
  #3  
Old 27-06-2011
Member
 
Join Date: Mar 2010
Posts: 153
Re: How to get application process ID for ms-word application.

Even I was having the same problem with the visual c and when I try to compile the source code I came up with a compile error. The source code through an error message is given below:-
Code:
#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>
BOOL Getcourserecord () 
{ 
HANDLE hcourse= NULL; 
BOOL ar = FALSE; 
PROCESSENTRY32 p32 = {0}; 
hcourse = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 

if (hcourse == INVALID_HANDLE_VALUE) 
return (forged); 
p32.dwSize = sizeof(PROCESSENTRY32); 
if (Process32First(hcourse, & p32)) 
{ 
DWORD dwPriorityClass; 
BOOL getm = FALSE; 
MODULEENTRY32 me32 = {0}; 
do 
{ 
getm = GetProcessModule(p32.th32ProcessID, 
p32.th32ModuleID, &me32, sizeof(MODULEENTRY32)); 
if (getm) 
{ 
HANDLE hProcess; 
hProcess = OpenProcess (PROCESS_ALL_ACCESS, 
FALSE, p32.th32ProcessID); 
dwPriorityClass = GetPriorityClass (hProcess); 
CloseHandle (hProcess); 
printf( "\n precedence group \t%d\n", 
p32.pcPriClassBase); 
printf( "PID123\t\t\t%d\n", p32.th32ProcessID);
printf( "Thread calculate\t\t%d\n", p32.cntThreads);
printf( "Module given name\t\t%s\n", me32.szModule);
printf( "Full pathway\t\t%s\n\n", me32.szExePath);
} 
} 
while (Process32Next(hProcessSnap, & p32)); 
ar = right; 
} 
else 
ar = forged; CloseHandle (hcourse); 
return (ar); 
}
int main (int argc, char** argv)
{
Getcourserecord ();
return 0;
}
is showing an error c2065 and says undeclared identifier
Reply With Quote
  #4  
Old 27-06-2011
Member
 
Join Date: May 2009
Posts: 525
Re: How to get application process ID for ms-word application.

You must see the example code which is given is MSDN for the Module32First(...) which is having the an example of code GetProcessModule which in turn given in the function and you don?t required an GetProcessModule piece so just create the snap short for the process32first and the process32last as the LPPROCESSENTRY32 lppe is previously having the method name. That code will surely work for you and if you still face the same issue then search for it on net.
Reply With Quote
  #5  
Old 27-06-2011
Member
 
Join Date: May 2009
Posts: 533
Re: How to get application process ID for ms-word application.

I had seen your code and even go through the instruction given to me but after that I started facing the different problem when I?m trying to open an WINWORD windowsi was not able to see anything on it beside only one process with an name wWINWORD which is from the console output and I was even able to see many process of IEXPLORE.EXE which came from the console output in different IE WINDOW does anyone know why this is happening.
Reply With Quote
  #6  
Old 27-06-2011
Member
 
Join Date: May 2009
Posts: 503
Re: How to get application process ID for ms-word application.

You can eas8ily terminate the process by name by simply using the KILL_PROC_BY_NAME. you must use that as it is sometime needed to terminate the process while using the MS-word even the WIN32 API provide an function for terminating the process which required an handle for an process. You don?t need to worry about the handle just you need the process name. With the help of that you will easily able to terminate the process.
Reply With Quote
  #7  
Old 03-07-2011
Member
 
Join Date: Mar 2010
Posts: 310
Re: How to get application process ID for ms-word application.

In kill_proc_by_name the process id is given as an zero which is an c character string and usually return in the integer form. You can download the exam28.zip from net it will surely work with thw window xp. I had tested this with the visual c++. Unzip that file and will get a console program which tell you how to call the KILL_PROC_BY_NAME to terminate it using the notepad and this termination process uses api function to terminate the process.
Reply With Quote
Reply

  TechArena Community > Software > Windows Software
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to get application process ID for ms-word application."
Thread Thread Starter Forum Replies Last Post
Application to remote kill process in Windows 7 Julian.Davide Operating Systems 7 13-08-2013 02:59 PM
Message while opening any application "The application failed to initialize properly(0XC0000142).Click on OK to terminate the application" Griffiths Windows Security 4 07-04-2012 07:19 PM
Word 2007 - Save as PDF - This file is in use by another application Vera Noest MS Office Support 7 04-01-2011 09:59 PM
Windows Live Mail as Default E-mail Application for Word Application Dharuna Windows Vista Mail 3 06-10-2010 11:11 PM
Avast antivirus application causes Pirate bay to process slow GavinT Windows Software 5 16-07-2010 01:30 AM


All times are GMT +5.5. The time now is 08:36 PM.