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. callback in windows service

callback in windows service

Scheduled Pinned Locked Moved C / C++ / MFC
help
7 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.
  • _ Offline
    _ Offline
    _tasleem
    wrote on last edited by
    #1

    hi all i want to implement windows hooks in service.i had implemented the hooks at the standard application(as DLL) it works fine.but the problem is that it did not worked for the service. i mean callback function is not called when service executed. tell me what i do. any help is welcomed.

    Tasleem Arif

    M 1 Reply Last reply
    0
    • _ _tasleem

      hi all i want to implement windows hooks in service.i had implemented the hooks at the standard application(as DLL) it works fine.but the problem is that it did not worked for the service. i mean callback function is not called when service executed. tell me what i do. any help is welcomed.

      Tasleem Arif

      M Offline
      M Offline
      Milton Karimbekallil
      wrote on last edited by
      #2

      Nt services are running in a difrent window station and desktop called -Service0x0-3e7$\default. All our applications are under Winsta0\default. So there may not be any applications running with an associated window object to invoke the hooked WindoProc. Try by changing the service type to SERVICE_INTERACTIVE_PROCESS so that the service will run under Winsta0\default desktop. cheers...Milton KB

      _ 1 Reply Last reply
      0
      • M Milton Karimbekallil

        Nt services are running in a difrent window station and desktop called -Service0x0-3e7$\default. All our applications are under Winsta0\default. So there may not be any applications running with an associated window object to invoke the hooked WindoProc. Try by changing the service type to SERVICE_INTERACTIVE_PROCESS so that the service will run under Winsta0\default desktop. cheers...Milton KB

        _ Offline
        _ Offline
        _tasleem
        wrote on last edited by
        #3

        i think u did not understand my question. i had implemented hooks as dll and used in desktop application and it works fine.when i use the same dll from service then it did not work i mean setwidows hooks is called and the callback function in response to hook is not called. and my service is controlled by the SCM and present in services list in the controll panel->admntool->services. how to do that in i mean changing service type. -- modified at 6:05 Wednesday 16th August, 2006

        Tasleem Arif

        M 1 Reply Last reply
        0
        • _ _tasleem

          i think u did not understand my question. i had implemented hooks as dll and used in desktop application and it works fine.when i use the same dll from service then it did not work i mean setwidows hooks is called and the callback function in response to hook is not called. and my service is controlled by the SCM and present in services list in the controll panel->admntool->services. how to do that in i mean changing service type. -- modified at 6:05 Wednesday 16th August, 2006

          Tasleem Arif

          M Offline
          M Offline
          Milton Karimbekallil
          wrote on last edited by
          #4

          I had understood what exactly u meant. Ur windows hook is not working in a service app while it works fine in a desktop application. This is what I understood before and now as well. The answer is same as before. Hope you are aware of the fact that the Desktop window is the parent window of all other windows we create using Createwindow() API. Actually this desktop what we are seeing is just one among a number of other desktops which Windows OS keeps invisible(some of them are visible as well. eg: logon desktop). This is a mystery to most of us. Actually there is something called a window station and a window station can have n number of desktops in it. A window station is a secure kernel object that contains a clipboard, a private atom table, a set of desktops, and a set of windows. see the info http://www.pluralsight.com/wiki/default.aspx/Keith.GuideBook/WhatIsAWindowStation.html[^] All our applications (including your desktop application what you were talking about) are running under a desktop called Winsta0\default. But NT Services are running in a different window station and desktop called Service0x0-3e7$\default. Your hook will not get invoked as there are no windows in the service desktop. So try by changing the service type to SERVICE_INTERACTIVE_PROCESS so that the service will run under Winsta0\default desktop and you will start getting the notifications in the windows hook. cheers Milton KB

          _ 1 Reply Last reply
          0
          • M Milton Karimbekallil

            I had understood what exactly u meant. Ur windows hook is not working in a service app while it works fine in a desktop application. This is what I understood before and now as well. The answer is same as before. Hope you are aware of the fact that the Desktop window is the parent window of all other windows we create using Createwindow() API. Actually this desktop what we are seeing is just one among a number of other desktops which Windows OS keeps invisible(some of them are visible as well. eg: logon desktop). This is a mystery to most of us. Actually there is something called a window station and a window station can have n number of desktops in it. A window station is a secure kernel object that contains a clipboard, a private atom table, a set of desktops, and a set of windows. see the info http://www.pluralsight.com/wiki/default.aspx/Keith.GuideBook/WhatIsAWindowStation.html[^] All our applications (including your desktop application what you were talking about) are running under a desktop called Winsta0\default. But NT Services are running in a different window station and desktop called Service0x0-3e7$\default. Your hook will not get invoked as there are no windows in the service desktop. So try by changing the service type to SERVICE_INTERACTIVE_PROCESS so that the service will run under Winsta0\default desktop and you will start getting the notifications in the windows hook. cheers Milton KB

            _ Offline
            _ Offline
            _tasleem
            wrote on last edited by
            #5

            thanks for such a descriptive answer, how can i change the service type to SERVICE_INTERFACTIVE_PROCESS only change the create service paramter to this or had to call different api calls for that purpose. one thing Thank U very Much Again.:)

            Tasleem Arif

            M 1 Reply Last reply
            0
            • _ _tasleem

              thanks for such a descriptive answer, how can i change the service type to SERVICE_INTERFACTIVE_PROCESS only change the create service paramter to this or had to call different api calls for that purpose. one thing Thank U very Much Again.:)

              Tasleem Arif

              M Offline
              M Offline
              Milton Karimbekallil
              wrote on last edited by
              #6

              Yes u can use SERVICE_INTERFACTIVE_PROCESS in ur CreateService call. cheers..Milton KB

              _ 1 Reply Last reply
              0
              • M Milton Karimbekallil

                Yes u can use SERVICE_INTERFACTIVE_PROCESS in ur CreateService call. cheers..Milton KB

                _ Offline
                _ Offline
                _tasleem
                wrote on last edited by
                #7

                it did not work callback function is not called through this technique as well.i had found an article related to the interactive servies at the codeproject.com here is its link [it was showing the icon in the tray what i did is replace the code of showing icons with the method of calling/registering hook's dll. The func of dll that hook the windows.but it did not work 2.Now i had one method use the timer to check whether it will be called or not. i dont have any thing in mind what to do next.

                Tasleem Arif

                ](http://www.codeproject.com/system/iconservice.asp)

                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