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. Global hook performance...

Global hook performance...

Scheduled Pinned Locked Moved C / C++ / MFC
wpfcomperformancequestion
2 Posts 2 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.
  • D Offline
    D Offline
    Dana Holt
    wrote on last edited by
    #1

    I am working on a project that requires a global hook. I only need to process a single message (WM_ACTIVATE), and I am using a WH_CALLWNDPROCRET type hook. Basically if I get this message I fire off another thread in the DLL that runs at THREAD_PRIORITY_LOWEST that modifies some of the window's styles. Anyway, when the hook is running taskmgr takes about 30% - 40% of the CPU time with nothing else going on. I assume this is from processing the messages because moving the mouse quickly increases this to 50% - 60%. The first thing I do in the hook is check if it is the message I want, and if it is not I call the next hook. I am also checking for nCode < 0 and calling the next hook without executing mine if this is true. Can anyone tell me what the best performance hook is? I think it is weird that the hook causes that much CPU usage in taskmgr. Oh, yes I am using DisableThreadLibraryCalls() for each process that uses the DLL. Thanks! -- Dana Holt Xenos Software

    A 1 Reply Last reply
    0
    • D Dana Holt

      I am working on a project that requires a global hook. I only need to process a single message (WM_ACTIVATE), and I am using a WH_CALLWNDPROCRET type hook. Basically if I get this message I fire off another thread in the DLL that runs at THREAD_PRIORITY_LOWEST that modifies some of the window's styles. Anyway, when the hook is running taskmgr takes about 30% - 40% of the CPU time with nothing else going on. I assume this is from processing the messages because moving the mouse quickly increases this to 50% - 60%. The first thing I do in the hook is check if it is the message I want, and if it is not I call the next hook. I am also checking for nCode < 0 and calling the next hook without executing mine if this is true. Can anyone tell me what the best performance hook is? I think it is weird that the hook causes that much CPU usage in taskmgr. Oh, yes I am using DisableThreadLibraryCalls() for each process that uses the DLL. Thanks! -- Dana Holt Xenos Software

      A Offline
      A Offline
      Alex Cramer
      wrote on last edited by
      #2

      I'm use WH_GETMESSAGE and WH_SHELL hooks in my program without any strange performance effects. Why do you need to create separate thread? I'm perform needed actions by posting message (PostMessage API) in main window when I plan to do long time action handling (because PostMessage don't stops the thread), and by sending message (SendMessage API) for simple actions. Sorry for wrong English ;-))

      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