detect if ActiveX control being used in .NET application? 
Author Message
 detect if ActiveX control being used in .NET application?

Hi,

Is there an easy way to tell from within
my ActiveX control (implemented in VC6++)
whether the application the control is
is being used is a .NET application (or win32)?

Thanks
-Gary



Tue, 28 Jun 2005 03:40:59 GMT  
 detect if ActiveX control being used in .NET application?
The common language runtime exposes COM objects through a proxy called the
runtime callable wrapper (RCW). Although the RCW appears to be an ordinary
object to .NET clients, its primary function is to marshal calls between a
.NET client and a COM object. It seem have not interface to detect its
container type.

You can try to know current process load CLR or not.  So you can check
Mscoree.dll load or not.

Best Regards

Jian Shen

This posting is provided "AS IS" with no warranties, and confers no rights.



Tue, 28 Jun 2005 14:38:00 GMT  
 detect if ActiveX control being used in .NET application?
If mscoree.dll is not loaded in a process, you could safely assume that the
ActiveX control is not being used in a .NET application.  If you wanted to
detect whether the ActiveX control itself was being used by .NET code (as
opposed to detect if some unrelated .NET code also happens to be running in
a process), you'd need to do some stack walking, and look for mscoree,
mscorlib, or System.Windows.Forms, but I guess by specifying 'easy' in your
question, this is something you'd prefer to avoid.

Nick Wienholt, MVP
Sydney Deep .NET User Group www.sdnug.org


Quote:
> Hi,

> Is there an easy way to tell from within
> my ActiveX control (implemented in VC6++)
> whether the application the control is
> is being used is a .NET application (or win32)?

> Thanks
> -Gary



Tue, 28 Jun 2005 15:09:30 GMT  
 detect if ActiveX control being used in .NET application?

Quote:
> If mscoree.dll is not loaded in a process, you could safely assume
> that the ActiveX control is not being used in a .NET application.  If
> you wanted to detect whether the ActiveX control itself was being
> used by .NET code (as opposed to detect if some unrelated .NET code
> also happens to be running in a process), you'd need to do some stack
> walking, and look for mscoree, mscorlib, or System.Windows.Forms, but
> I guess by specifying 'easy' in your question, this is something
> you'd prefer to avoid.

That stack walking is unlikely to help much in practice as it would find
cases like <managed> -> <native code via p/invoke, ijw, or com interop> ->
<ActiveX control> which would give a false-positive (not to mention
cross-apartment calls could easily lead to <managed>-><ActiveX control>
usage that happens via COM marshalling.)  Perhaps most insidiously you could
have a managed message-pump (pumping messages for an unrelated managed
dialog that gets popped-up) which ends up directing calls to the ActiveX
control purely by virtue of running a message pump.

--
Jeff Peil



Tue, 28 Jun 2005 18:21:53 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Problem in distribution of applications using MSComm Control (ActiveX Control)

2. using windows media player activeX control with .NET

3. Using enum/ v1_enum in ATL Activex Control in VS .Net

4. using ActiveX control in an MFC application

5. Using ActiveX Control in a Dialog-Based AppWizard Application

6. Using ActiveX controls in MFC applications

7. Sample SDI application using ActiveX controls

8. Developing mfc activex control and using ActiveX SDK-question

9. Problem using VB 5 activex DLL in a VC++ activex control

10. Control webbrowser ActiveX control in composit ActiveX control

11. Problem Hosting ActiveX Controls Using ATL AXHost (CAxWindow2) using VC7

12. embed an VC++6.0 ActiveX in a VC++.net Application

 

 
Powered by phpBB® Forum Software