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. SetWindowsHookEx under Windows Service

SetWindowsHookEx under Windows Service

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
4 Posts 4 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.
  • F Offline
    F Offline
    FotisSs
    wrote on last edited by
    #1

    Is it possible for a service under windows XP to hook for example mouse or keyboard? I have tried to call SetWindowsHookEx inside a windows service but the callback function receives no messages. If yes how can it be done. I know already about desktop interactive option for a service and SetTheadDesktop etc but none of them work. I also tried impersonation, to give the hooking thread a specific process token no luck there too. Thanx

    _ M 2 Replies Last reply
    0
    • F FotisSs

      Is it possible for a service under windows XP to hook for example mouse or keyboard? I have tried to call SetWindowsHookEx inside a windows service but the callback function receives no messages. If yes how can it be done. I know already about desktop interactive option for a service and SetTheadDesktop etc but none of them work. I also tried impersonation, to give the hooking thread a specific process token no luck there too. Thanx

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      I guess it will not work in the default SYSTEM account. Check it by running the service in another user context.

      «_Superman_» I love work. It gives me something to do between weekends.
      Microsoft MVP (Visual C++)

      I 1 Reply Last reply
      0
      • _ _Superman_

        I guess it will not work in the default SYSTEM account. Check it by running the service in another user context.

        «_Superman_» I love work. It gives me something to do between weekends.
        Microsoft MVP (Visual C++)

        I Offline
        I Offline
        IvanProg
        wrote on last edited by
        #3

        I have the same problem. Service sets out under the Admin account. SetWindowsHookEx does not intercept the message, what's the problem?

        1 Reply Last reply
        0
        • F FotisSs

          Is it possible for a service under windows XP to hook for example mouse or keyboard? I have tried to call SetWindowsHookEx inside a windows service but the callback function receives no messages. If yes how can it be done. I know already about desktop interactive option for a service and SetTheadDesktop etc but none of them work. I also tried impersonation, to give the hooking thread a specific process token no luck there too. Thanx

          M Offline
          M Offline
          mirushaki
          wrote on last edited by
          #4

          I have the same trouble too.

          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