Results 1 to 10 of 10
  1. #1

    Default How can I kill a process using C++?


    How can I kill a process using C++?

  2. #2

    Default Re: How can I kill a process using C++?

    using API, or kung naay existing exe nga mo kill na ug process then run it with parameter, or using vbscript kung pwede tawagon sa c++.

  3. #3

    Default Re: How can I kill a process using C++?

    If you are using the ISO standard C++, I think lisud ni siya same ra pud kung mo create a ug directory.

    I think ang mas maayo ani is motawag ka ug C functions/API.

  4. #4

    Default Re: How can I kill a process using C++?

    i know exactly what you need

    steps
    1.) obtain the processID
    either by looping through all the current process. using the CreateToolhelp32Snapshot in combination of Process32First, Process32Next,CloseHandle, and ProcessEntry32(structure) you check the name if its equal to the process your are looking for.

    or using the FindWindow API with that you get the handle for the process... theirs a function to get the processID from a handle GetWindowThreadProcessId so you use that processID

    2.) after obtaining the process id you use OpenProcess, then Call TerminateProcess, and then close the handle with CloseHandle

    now a little research about this APIs woudn't hurt.

  5. #5

    Default Re: How can I kill a process using C++?

    give me a sample code please. ty

  6. #6

    Default Re: How can I kill a process using C++?

    Try kuno read sa Windows API. Para at least kahibalo ka mo basa ug API.

    http://msdn2.microsoft.com/en-us/library/aa383750(VS.85).aspx

  7. #7

    Default Re: How can I kill a process using C++?

    nka try nman ko ug win api..pero wala nka include ang advance sa ako na download nga tutorial.... mga dlg box raman to ug bitmaps.....

    Quote Originally Posted by silent-kill
    CreateToolhelp32Snapshot
    Process32First
    Process32Next
    CloseHandle

    ProcessEntry32(structure)

    FindWindow API

    processID
    GetWindowThreadProcessId
    OpenProcess
    TerminateProcess
    CloseHandle
    UNsa man ang ilang mga aguments aning mga functions ug unsa pud ang mga object nga naa sa ProcessEntry32?
    give pud some links about sa FindWindow API ..

  8. #8

    Default Re: How can I kill a process using C++?

    this is how you get the handle of the process.
    Code:
    HANDLE GetProcessHandle(LPSTR szExeName)
    {
      PROCESSENTRY32 Pc = { sizeof(PROCESSENTRY32) };
      HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
      if(Process32First(hSnapshot, &Pc)){
        do{
          if(!strcmp(Pc.szExeFile, szExeName)) {
            return OpenProcess(PROCESS_ALL_ACCESS, TRUE, Pc.th32ProcessID);
          }
        }while(Process32Next(hSnapshot, &Pc));
      }
      return NULL;
    }
    after that.. call TerminateProcess..
    in your main like

    Code:
      HANDLE hProcess = GetProcessHandle("iexplore.exe");
      DWORD fdwExit = 0;
      GetExitCodeProcess(hProcess, &fdwExit);
      TerminateProcess(hProcess, fdwExit);
      CloseHandle(hProcess);
    i think in c++ PROCESSENTRY32 is already declared kong wala pa... mao ni siya
    http://msdn2.microsoft.com/en-us/library/ms684839(VS.85).aspx

  9. #9

    Default Re: How can I kill a process using C++?

    tnx..... got it...

  10. #10
    there is a built in program sa windows, tasklist and taskkill i think you could use it if your in windows platform.

  11.    Advertisement

Similar Threads

 
  1. How can you know if a guy/your BF is in love with you?
    By chaise18 in forum "Love is..."
    Replies: 110
    Last Post: 09-10-2015, 12:59 PM
  2. Replies: 7
    Last Post: 03-23-2013, 12:29 AM
  3. Replies: 6
    Last Post: 02-07-2011, 10:37 AM
  4. how can i use an external speaker for my ps3?
    By windsong in forum Computer Hardware
    Replies: 2
    Last Post: 03-11-2009, 12:38 PM
  5. How can I delete a post na posted at a wrong forum?:)
    By marinee in forum Support Center
    Replies: 3
    Last Post: 04-23-2005, 04:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top