Question:
For a Windows Service How to check the check box "Allow service to interact with desktop" programatically using .Net
Solution:
Its little bit tricky to do this. To achieve this you must deal with Windows Registry of the Local machine where exactly the Service is running. Add the following code snippet and call before the service OnStart() Method. Thats all!
Microsoft.Win32.RegistryKey seviceKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\YourServiceName", true);
if (seviceKey != null)
{
if (seviceKey.GetValue("Type") != null)
seviceKey.SetValue("Type", ((int)seviceKey.GetValue("Type") | 256));
}
With regards,
Francis Michael.
Friday, January 11, 2008
How to check the check box "Allow service to interact with desktop" programatically in .Net
Posted by
FrancisMichael
at
10:05 PM
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment