I'm trying to connect an event handler to the BeforeNavigate2 event of
Internet Explorer. This works in a Windows app, but I can't get it to work
in a Windows service. I get the following exception when I run the line
"shellWindo ws = new SHDocVw.ShellWi ndowsClass();":
COM object with CLSID {9BA05972-F6A8-11CF-A442-00A0C90A8F39} is either not
valid or not registered.
I know that this CLSID belongs to the ShellWindows interface.
Any ideas?
Here's the source code:
namespace WindowsService1
{
public class Service1 : System.ServiceP rocess.ServiceB ase
{
private System.Componen tModel.Containe r components = null;
private static SHDocVw.ShellWi ndows shellWindows = null; //<=====
public Service1()
{
InitializeCompo nent();
}
static void Main()
{
System.ServiceP rocess.ServiceB ase[] ServicesToRun;
ServicesToRun = new System.ServiceP rocess.ServiceB ase[] { new
Service1() };
System.ServiceP rocess.ServiceB ase.Run(Service sToRun);
if(!EventLog.So urceExists("Ser vice1"))
{
EventLog.Create EventSource("Se rvice1", "Applicatio n");
}
}
private void InitializeCompo nent()
{
this.ServiceNam e = "Service1";
}
protected override void Dispose(bool disposing)
{
if(disposing)
{
if(components != null)
{
components.Disp ose();
}
}
base.Dispose(di sposing);
}
protected override void OnStart(string[] args)
{
EventLog.WriteE ntry("Service1" , "0.This is just a test.",
EventLogEntryTy pe.Information) ;
shellWindows = new SHDocVw.ShellWi ndowsClass(); //<=====
foreach(SHDocVw .InternetExplor er ie in shellWindows) //<=====
ie.BeforeNaviga te2 += new
SHDocVw.DWebBro wserEvents2_Bef oreNavigate2Eve ntHandler(this. ie_BeforeNaviga t
e2); //<=====
}
public void ie_BeforeNaviga te2(object disp, ref object url, ref
object flags, ref object targetFrameName , ref object postData, ref object
headers, ref bool cancel) //<=====
{
EventLog.WriteE ntry("Service1" , "ie_BeforeNavig ate2.",
EventLogEntryTy pe.Information) ; //<=====
}
protected override void OnStop()
{
}
}
} 2 2654
Hello,
Thanks for your post. As I understand, the problem you are facing is that
it fails to enumerate existing IE windows from a Windows Service. Please
correct me if there is any misunderstandin g. I now share the following
information with you:
Based on my experience, I believe the reason of the problem is that a
Windows Service is running in a hidden window station and desktop other
than "WinSta0\Defaul t". To work around this problem, you may have to set
your service as an interactive service b the following steps:
1. Go to "Control Panel" -> "Service".
2. Select the service in list box and click "Startup" button.
3. Select "System Account" and check "Allow Service to Interact with
Desktop".
I belive the following article is helpful:
Interacting with the User in a Service http://msdn.microsoft.com/library/de...us/dllproc/bas
e/interacting_wit h_the_user_in_a _service.asp
I look forward to your result.
Regards,
HuangTM
Microsoft Online Partner Support
MCSE/MCSD
Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Hello,
Thanks for your post. As I understand, the problem you are facing is that
it fails to enumerate existing IE windows from a Windows Service. Please
correct me if there is any misunderstandin g. I now share the following
information with you:
Based on my experience, I believe the reason of the problem is that a
Windows Service is running in a hidden window station and desktop other
than "WinSta0\Defaul t". To work around this problem, you may have to set
your service as an interactive service b the following steps:
1. Go to "Control Panel" -> "Service".
2. Select the service in list box and click "Startup" button.
3. Select "System Account" and check "Allow Service to Interact with
Desktop".
I belive the following article is helpful:
Interacting with the User in a Service http://msdn.microsoft.com/library/de...us/dllproc/bas
e/interacting_wit h_the_user_in_a _service.asp
I look forward to your result.
Regards,
HuangTM
Microsoft Online Partner Support
MCSE/MCSD
Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: SunshineGirl |
last post by:
I'm trying to connect an event handler to the BeforeNavigate2 event of
Internet Explorer. This works in a Windows app, but I can't get it to work
in a Windows service. I get the following exception when I run the line
"shellWindows = new SHDocVw.ShellWindowsClass();":
COM object with CLSID {9BA05972-F6A8-11CF-A442-00A0C90A8F39} is either not
valid or not registered.
I know that this CLSID belongs to the ShellWindows interface.
|
by: SunshineGirl |
last post by:
In my code, class A instanciates classes B and C.
I would like class B to connect an event handler to a method in class A, and
for class C to disconnect that event handler.
I think I've done too much thinking, and now I'm even more confused as to
how to accomplish this as when I started.
Any help will be appreciated.
|
by: David |
last post by:
Hi,
Ive been trying to work this out for the past 2 days now and im not
getting anywhere fast.
The problem i have is that i am using Asynchronous sockets to create a
Socket Client library. When i try to connect to a server that doesnt
exist it raises a "Connection forcibly rejected by the resmote host"
SocketException.
|
by: Stampede |
last post by:
Hi guys 'n' girls,
I want to use callback methods when using BeginInvoke on some events. So far
no problem, but know I thought about what could happen (if I'm not completly
wrong).
Lets say an event is triggerd with BeginInvoke and a callback funktion which
is part of the instanze which is also holding the event. So the call looks
something like this:
public class MyClass {
|
by: John |
last post by:
Hi
I am trying to get web reference to my first (!) web service which is on a
remote host. I am getting the following error;
Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom
error settings for this application prevent the details of the application
| |
by: Kevin Antel |
last post by:
We have written a service that uses a timer control to check for a process
every 60 seconds. This is installed on a Windows 2003 Server w/SP1.
The problem we are running into is that the service doesn't stop, but it
seems the timer process stops. Has anyone else run into this? What have
been solutions?
|
by: len.hartley |
last post by:
Hi,
I am trying to pop-up a window when the user clicks on an image. The
problem is that when the user clicks on the image and the window pops
up OK, but the window underneath also proceeds to the image. The
desired behavior is that when the pop-up is invoked, I want the
underlying window to stay put.
I don't have this problem when I run the code on my local computer but
I do have it when I run the code on geocities.
|
by: Suresh |
last post by:
Hi Guys
I have Db2 server installed on remote server. i am connecting to that
remote server by using VPN.
I want to connect that remote DB2 server instance using my local
machine DB2 development client. Bur Its gives me following error
message. I searched lots of things on net and tried on remote server
but i didnt got suceess. Can any one tell me how to set TCP\IP
connection protocol on server for particular instance. Becuase I think
|
by: chitra g |
last post by:
Hi,
I tried all the options below but did not work.
Your suggestions please.
|
by: Simon |
last post by:
Hi all,
I'm having a problem creating a global exception handler in a windows
service that I'm making. Another poster suggested that the way to do
this was to use the CurrentDomain.UnhandledException event to catch and
deal with any exception that crops up. The problem is, when I try and
deliberately throw an exception in my services OnStart event handler,
nothing seems to happen. By that I mean, the
CurrentDomain_UnhandledException...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |