Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8799513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:20:39+00:00 2026-06-14T00:20:39+00:00

I need to create a COM object which is callable from Javascript. I’ve been

  • 0

I need to create a COM object which is callable from Javascript. I’ve been told that to do this, you need a COM object which also implements a class factory and it was suggested here that I try ATL. Someone pointed me to a Code Project ATL sample, however that doesn’t cover the class factory.

I’m able to build a small ATL project with a simple object, but am unable to instantiate it, presumable because I haven’t provided the class factory.

So, does anyone have experience building a simple COM object in VS2010 via ATL which can be called from Javascript?

EDIT: well, in reading the documentation for the DECLARE_CLASSFACTORY_EX it sounds like a default class factory IS provided. So now I’m not sure what’s missing. What is needed to instantiate and invoke the class from Javascript?

EDIT: Also, to clarify, the Javascript where I’m calling the object from is in an HTML page being shown in the IE ActiveX control in an MFC dialog app. So that’s the context in which the Javascript will run.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:20:41+00:00Added an answer on June 14, 2026 at 12:20 am

    First of all, I believe you mean MS-specific JScript for Internet Explorer, because other browsers might not support COM/ActiveX.

    You don’t have to implement class-factory explicitly, because ATL framework already provides it. Just run ATL wizard: View –> Class view; in Class view right-click project root –> Add –> Class –> ATL Simple Object; set class name, and leave the defaults for all the rest. The wizard will define the following main things:

    1. Interface and co-class that implements it, in IDL file.
    2. C++ class, which would be the actual implementation of the above co-class. Pay attention to OBJECT_ENTRY_AUTO macro in the header file: it “connects” between your class and the ATL framework class-factory.
    3. *.rgs file, which is used to register your co-class in Windows registry.

    Now you can add some methods to this newly created class – by means of wizard (right-click on class –> Add –> Add Function…), or manually.

    Besides, in order to avoid security issues with your component, you have to implement IObjectSafety in your class: just inherit the c++ class from public IObjectSafetyImpl<CYourClass, INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA>, and add COM_INTERFACE_ENTRY(IObjectSafety) to the interface map.

    Now your class is ready for use from within JScript. In the script you can either create it statically, using object tag, or dynamically, using new ActiveX() statement. If your object has connection-points (i.e. fires events) and you don’t want to be too tricky, you have to use the former approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create this url: www.example.com/directory/[state]-financial-planners Where [state] will be different depending on
I need to dynamically create com objects from an activex dll and each of
I have a VB6 COM component which I need to call from my .Net
I need to make a Javascript object that would behave as an associative array,
Need to create a custom DNS name server using C which will check against
I need to create a WP site which will have multiple subjects. Each subject
I'm trying to create an ObjC application that will control iTunes. I need a
Following code create that Annotation. As described here, http://engineering.webengage.com/2012/03/12/a-peek-into-webengages-security-layer-super-cool-use-of-java-annotations /** * Defining the Asynch
I have an ATL COM object which needs to expose a collection of other
I have a C# application which uses a COM component. This COM component require

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.