Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. suspend process

suspend process

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    uttit
    wrote on last edited by
    #1

    hi all,i have a problem with suspending a process. Could someone help me? Thanks a lot!:rolleyes:

    M Y 2 Replies Last reply
    0
    • U uttit

      hi all,i have a problem with suspending a process. Could someone help me? Thanks a lot!:rolleyes:

      M Offline
      M Offline
      Mike Beckerleg
      wrote on last edited by
      #2

      I expect we will be able to help you if you tell us what the problem is. Mike

      1 Reply Last reply
      0
      • U uttit

        hi all,i have a problem with suspending a process. Could someone help me? Thanks a lot!:rolleyes:

        Y Offline
        Y Offline
        yanping wang
        wrote on last edited by
        #3

        here are some code used to suspend a process. since I do not known the exact problem you meet, I only show it for you: BOOL WINAPI SuspendProcess(DWORD dwProcessID, BOOL bSuspend) { // 取得OpenThread函数的地址 typedef HANDLE (__stdcall *PFNOPENTHREAD)(DWORD, BOOL, DWORD); HMODULE hModule = ::GetModuleHandle("kernel32.dll"); PFNOPENTHREAD OpenThread = (PFNOPENTHREAD)::GetProcAddress(hModule, "OpenThread"); if(OpenThread == NULL) return FALSE; // 取得指定进程内的线程列表 HANDLE hSnap; hSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, dwProcessID); if(hSnap != INVALID_HANDLE_VALUE) { // 遍历线程列表 THREADENTRY32 te = { 0 }; te.dwSize = sizeof(te); BOOL bOK = ::Thread32First(hSnap, &te); while(bOK) { if(te.th32OwnerProcessID == dwProcessID) { DWORD dwID = te.th32ThreadID; // 试图打开这个线程 HANDLE hThread = OpenThread(THREAD_SUSPEND_RESUME, FALSE, dwID); if(hThread != NULL) { // 暂停或者唤醒这个线程 if(bSuspend) ::SuspendThread(hThread); else ::ResumeThread(hThread); ::CloseHandle(hThread); } } bOK = ::Thread32Next(hSnap, &te); } ::CloseHandle(hSnap); } return TRUE; } I am a Chinese man, so the commentary is in Chinese. Regards

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups