Yes, I know it is not recommended, but there are times when we need
this, even if only for limited periods of time.
Is there no way to enable this in the compilation.build phase? Must it
be enabled only after the service is installed? IN one case we have a
single project that contains multiple services, and we wanted to have a
single form displayed that included information from all of the services.
-ken
> I would not recommend that you display a user interface from a .NET
> service. If you really want to, you CAN allow it to interact with the
[quoted text clipped - 19 lines]
>>
>> -Ken
Norman Yuan - 07 Jul 2005 20:35 GMT
Look into ServiceController Class, which is used for control Wndows
Services.
You can build a standard Win Form App on Service Controller class to
monitor/control the Windows Service(s). Almost all books on Windows Service
have an example of Win Form app, using ServiceController class.
> Yes, I know it is not recommended, but there are times when we need
> this, even if only for limited periods of time.
[quoted text clipped - 29 lines]
> >>
> >> -Ken
Andy - 18 Jul 2005 17:46 GMT
Create an installer class for your service project.
Override the Install method, like so:
public override void Install(IDictionary stateSaver) {
base.Install(stateSaver);
SetInteractWithDesktop();
}
private void SetInteractWithDesktop() {
RegistryKey fm;
ServiceType type;
fm = Registry.LocalMachine.OpenSubKey(
@"SYSTEM\CURRENTCONTROLSET\SERVICES\<your_service_name>, true );
type = ServiceType.InteractiveProcess |
ServiceType.Win32ShareProcess;
fm.SetValue( "Type", (int)type );
fm.Close();
}
That will modify the registry properly to check the Allow interaction
with desktop setting.
HTH.
Andy