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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Service Programming - How to tell if the current process is running as a Windows Service..

Service Programming - How to tell if the current process is running as a Windows Service..

Scheduled Pinned Locked Moved C / C++ / MFC
sysadmintutorialquestion
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.
  • M Offline
    M Offline
    Mike Doner
    wrote on last edited by
    #1

    I'm writing a .DLL that's being used in both our Client and Server application. Is there a windows call I can use that will tell me if the current process is running as a windows service or not? Thnx. M.

    I K N 3 Replies Last reply
    0
    • M Mike Doner

      I'm writing a .DLL that's being used in both our Client and Server application. Is there a windows call I can use that will tell me if the current process is running as a windows service or not? Thnx. M.

      I Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      Can't you use GetCurrentUser? I'm pretty sure that a service will default to LocalSystem, or such. I'm also pretty sure that it can do clever things like ImpersonateUser, etc, but you can't cover everything! Lastly, doesn't a service run from a different context, so GetDesktopWindow would fail? While not a black and white answer for you, I hope that helped. Iain.

      Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.

      1 Reply Last reply
      0
      • M Mike Doner

        I'm writing a .DLL that's being used in both our Client and Server application. Is there a windows call I can use that will tell me if the current process is running as a windows service or not? Thnx. M.

        K Offline
        K Offline
        KarstenK
        wrote on last edited by
        #3

        Use a flag which you can control. :rolleyes:

        Greetings from Germany

        1 Reply Last reply
        0
        • M Mike Doner

          I'm writing a .DLL that's being used in both our Client and Server application. Is there a windows call I can use that will tell me if the current process is running as a windows service or not? Thnx. M.

          N Offline
          N Offline
          Nibu babu thomas
          wrote on last edited by
          #4

          Mike Doner wrote:

          Is there a windows call I can use that will tell me if the current process is running as a windows service

          You can check whether one of the parent processes of this process is services.exe, user services are created via this process.

          Nibu babu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com

          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