windows service interact with desktop

G

Guest

Hi,

Im writing a widnows service and i want the service to interact with the
desktop. However, I do not want to go to control
panel->services->properties->logon and then selec the check box "Allow
service to interact with desktop". How can i do this in code. I know this
could be done in VC6. How do i do this in .NET.

I found the following code on the web and it sets the flag right but my
installer auto starts the service the service runs and the check box is
selected but when i try to open a messageboxes the service throws an exception
"It is invalid to show a modal dialog or form when the application is not
running in UserInteractive mode. Specify the ServiceNotification or
DefaultDesktopOnly style to display a notification from a service
application."
--CODE--
Microsoft.Win32.RegistryKey ckey =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\service1", true);
if(ckey != null)
{
if(ckey.GetValue("Type") != null)
{
ckey.SetValue("Type", ((int)ckey.GetValue("Type") | 256));
}
}
--CODE--

Also i get the following error when trying to enumerate all shellwindows
"COM object with CLSID {9BA05972-F6A8-11CF-A442-00A0C90A8F39} is either not
valid or not registered."
What could be the problem??
--


Regards,

M i s b a h A r e f i n
..NET Programmer
En Pointe Technologies
Reply to : (e-mail address removed)
www.enpointe.com
 
G

Guest

Gabriele this was the site i got the code in the first place... but it does
not work...
 
G

Guest

Can anyone please tell me why i am getting the following error

COM object with CLSID {9BA05972-F6A8-11CF-A442-00A0C90A8F39} is either not
valid or not registered.

I get the above error on this line of code

SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();

My service starts a process with credentials of local admin
CreatePRocessWithLogonW()... the service also starts another process which
displays a window on the desktop and it works fine
 
G

Guest

Misbah Arefin said:
Hi,

Im writing a widnows service and i want the service to interact with the
desktop. However, I do not want to go to control
panel->services->properties->logon and then selec the check box "Allow
service to interact with desktop". How can i do this in code. I know this
could be done in VC6. How do i do this in .NET.

I found the following code on the web and it sets the flag right but my
installer auto starts the service the service runs and the check box is
selected but when i try to open a messageboxes the service throws an exception
"It is invalid to show a modal dialog or form when the application is not
running in UserInteractive mode. Specify the ServiceNotification or
DefaultDesktopOnly style to display a notification from a service
application."
--CODE--
Microsoft.Win32.RegistryKey ckey =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\service1", true);
if(ckey != null)
{
if(ckey.GetValue("Type") != null)
{
ckey.SetValue("Type", ((int)ckey.GetValue("Type") | 256));
}
}
--CODE--

Also i get the following error when trying to enumerate all shellwindows
"COM object with CLSID {9BA05972-F6A8-11CF-A442-00A0C90A8F39} is either not
valid or not registered."
What could be the problem??
--


Regards,

M i s b a h A r e f i n
.NET Programmer
En Pointe Technologies
Reply to : (e-mail address removed)
www.enpointe.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top