Can I Retrieve A COM (ActiveX) Interface in C# From A Running Window Handle?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span style="font:16px/normal "Times New Roman"; color:#000000; text-transform:none; text-indent:0px; letter-spacing:normal; word-spacing:0px; white-space:normal; border-collapse:separate; orphans:2; widows:2 <span style="text-align:left; color:#333333; line-height:16px; font-family:"Segoe UI","Lucida Grande",Verdana,Arial,Helvetica,sans-serif; font-size:13px
<p style="border-width:0px; margin:1em 0px; padding:0px; font-family:inherit; font-style:inherit; font-weight:inherit; text-decoration:none; list-style-type:none; outline-width:0px
Hello,
<p style="border-width:0px; margin:1em 0px; padding:0px; font-family:inherit; font-style:inherit; font-weight:inherit; text-decoration:none; list-style-type:none; outline-width:0px
Im writing a 64-bit COM+ application in C# that acts as an automation bridge between our native 64-bit application and a 32-bit automated testing tool. Our application hosts custom 64-bit ActiveX controls inside both explore.exe and iexplorer.exe. These
controls are essentially image containers and my goal is to read custom properties from them and execute custom methods. The 32-bit testing tool recognizes these ActiveX controls only as generic window objects with ATL ids. Within my component
I would like to access them through our custom COM interfaces.
<p style="border-width:0px; margin:1em 0px; padding:0px; font-family:inherit; font-style:inherit; font-weight:inherit; text-decoration:none; list-style-type:none; outline-width:0px
Im doing this work on 64-bit Win7 Ultimate (IE8) using Visual Studio 2005.
<p style="border-width:0px; margin:1em 0px; padding:0px; font-family:inherit; font-style:inherit; font-weight:inherit; text-decoration:none; list-style-type:none; outline-width:0px
Ive been successful so far when the ActiveX controls are hosted directly on an IE page. I first attach to the running IE window using its handle and obtain the HTML interface from the Internet Explorer_Server object using ObjectFromLResult.
I then identify the ActiveX control as an IMAGE element on the page and cast the IHTMLElement to our custom ActiveX interface (which I include as a reference in my project). I can then simply get the properties and call the methods.
<p style="border-width:0px; margin:1em 0px; padding:0px; font-family:inherit; font-style:inherit; font-weight:inherit; text-decoration:none; list-style-type:none; outline-width:0px
Its works fine when our controls hosted directly on an IE page. However when theyre hosted inside explore.exe there are additional intermediate objects between the Internet Explorer_Server object and our image controls (mostly custom
shellview objects). The controls I want appear in VS Spy++ as child windows of the shellview objects and are not directly accessible as IHTMLElements through the HTML interface.
<p style="border-width:0px; margin:1em 0px; padding:0px; font-family:inherit; font-style:inherit; font-weight:inherit; text-decoration:none; list-style-type:none; outline-width:0px
I can identify the specific object I want using Win32 and get its handle.
<p style="border-width:0px; margin:1em 0px; padding:0px; font-family:inherit; font-style:inherit; font-weight:inherit; text-decoration:none; list-style-type:none; outline-width:0px
I would like to know if theres an alternative way to get an ActiveX interface from these objects when all I have is their handle?
<p style="border-width:0px; margin:1em 0px; padding:0px; font-family:inherit; font-style:inherit; font-weight:inherit; text-decoration:none; list-style-type:none; outline-width:0px
Thanks,
<p style="border-width:0px; margin:1em 0px; padding:0px; font-family:inherit; font-style:inherit; font-weight:inherit; text-decoration:none; list-style-type:none; outline-width:0px
Frank
<p style="border-width:0px; margin:1em 0px; padding:0px; font-family:inherit; font-style:inherit; font-weight:inherit; text-decoration:none; list-style-type:none; outline-width:0px
(I posted this in the automation forums and it was rejected.)
<p style="border-width:0px; margin:1em 0px; padding:0px; font-family:inherit; font-style:inherit; font-weight:inherit; text-decoration:none; list-style-type:none; outline-width:0px


<span style="font:16px/normal "Times New Roman"; color:#000000; text-transform:none; text-indent:0px; letter-spacing:normal; word-spacing:0px; white-space:normal; border-collapse:separate; orphans:2; widows:2 <span style="text-align:left; color:#333333; line-height:16px; font-family:"Segoe UI","Lucida Grande",Verdana,Arial,Helvetica,sans-serif; font-size:13px

View the full article
 
Back
Top