Results 1 to 7 of 7

Thread: How to get application process ID for ms-word application.

  1. #1
    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.

  2. #2
    Join Date
    Apr 2009
    Posts
    488

    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.

  3. #3
    Join Date
    Mar 2010
    Posts
    154

    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

  4. #4
    Join Date
    May 2009
    Posts
    529

    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.

  5. #5
    Join Date
    May 2009
    Posts
    543

    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.

  6. #6
    Join Date
    May 2009
    Posts
    511

    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.

  7. #7
    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.

Similar Threads

  1. Application to remote kill process in Windows 7
    By Julian.Davide in forum Operating Systems
    Replies: 7
    Last Post: 13-08-2013, 02:59 PM
  2. Replies: 4
    Last Post: 07-04-2012, 07:19 PM
  3. Replies: 7
    Last Post: 04-01-2011, 09:59 PM
  4. Replies: 3
    Last Post: 06-10-2010, 11:11 PM
  5. Replies: 5
    Last Post: 16-07-2010, 01:30 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,656,270.51831 seconds with 16 queries