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#
  4. the process and services...

the process and services...

Scheduled Pinned Locked Moved C#
questionworkspace
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.
  • W Offline
    W Offline
    Wail A Salem
    wrote on last edited by
    #1

    Hi every body i want to ask: how we can prevent the user from ending the process from the task manager? the a second question is how we can make the service interactive with the desktop i know that there is ServiceType calss but when i try to use it the service dos'nt interact with the desktop and here is the segment of the code which i wrote .......... ........... private void InitializeComponent() { this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller(); this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller(); // // serviceProcessInstaller1 // this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService; this.serviceProcessInstaller1.Password = null; this.serviceProcessInstaller1.Username = null; // // serviceInstaller1 // this.st=System.ServiceProcess.ServiceType.InteractiveProcess; this.serviceInstaller1.ServiceName = "Service2"; this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic; // // ProjectInstaller // this.Installers.AddRange(new System.Configuration.Install.Installer[] { this.serviceProcessInstaller1, this.serviceInstaller1,this.st }); .............. .............. note i install the service by setup project with regards

    H 1 Reply Last reply
    0
    • W Wail A Salem

      Hi every body i want to ask: how we can prevent the user from ending the process from the task manager? the a second question is how we can make the service interactive with the desktop i know that there is ServiceType calss but when i try to use it the service dos'nt interact with the desktop and here is the segment of the code which i wrote .......... ........... private void InitializeComponent() { this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller(); this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller(); // // serviceProcessInstaller1 // this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService; this.serviceProcessInstaller1.Password = null; this.serviceProcessInstaller1.Username = null; // // serviceInstaller1 // this.st=System.ServiceProcess.ServiceType.InteractiveProcess; this.serviceInstaller1.ServiceName = "Service2"; this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic; // // ProjectInstaller // this.Installers.AddRange(new System.Configuration.Install.Installer[] { this.serviceProcessInstaller1, this.serviceInstaller1,this.st }); .............. .............. note i install the service by setup project with regards

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Wail A.Salem wrote: how we can prevent the user from ending the process from the task manager? You can't. But you can respond to notification that a user is killing your process. Handle the Closing or Close event of your main form (the one you pass directly or indirectly to Application.Run). If your code is not finished in a timely manner, your process will be killed. There are a few other ways as well, but I'll leave this as an exercise for you. I recommend reading through the Windows Management APIs section of the MSDN Online Library[^]. As for the second question, you have to write this to the registry yourself. So add a registry key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\<YourServiceName>\Type such as 288 (256 for "Interact with desktop" OR'd with 32 for the service type), or whatever is appropriate for your service type so long as you perform a bitwise OR with 256 and run it as the LocalSystem (default). If you run it as a user, then the service can only interact with that user's desktop (assuming the user has an associated desktop session and can log in locally).

      Microsoft MVP, Visual C# My Articles

      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