?
Solved

How do I create a DLL to interface with JavaScript

Posted on 2011-04-19
3
Medium Priority
?
361 Views
Last Modified: 2012-06-27
I am new to DLL development so I followed the following tutorial on how I can create a COM DLL along with a Win32 application that calls its functions:
The Simplest COM Tutorial in Visual Studio 2008

This all worked as expected but my ultimate goal is to run the DLL from a scripting interface like JavaScript e.g.
try {
    var app = new ActiveXObject("SimpleCOM.SimpleChatServer.1");
    app.CallMe("Test 1","Test 2");
}
catch (e) {
    alert("Error: " +e.message);
}

Open in new window

The following example just returns the following error message:
"Error: 'app' is null or not an object"

I am also aware that the DLL needs to be registered which Visual Studio 2008 seems to do automatically. Using RegDllView I was able to see the DLL listed (Sorry for the lack of formatting)
Class ID       Name       ProgID       Control       Version       Threading Model       Last Write Time
{3C32480D-2799-41EC-8E9F-6CBFFC20D51B}      SimpleChatServer Class      SimpleCOM.SimpleChatServer.1      No             Apartment      19/04/2011 19:42:12

Does any one know what further steps are required so it can start interfacing with it via JavaScript e.g. allowing me to call setters and getters from within the DLL file.

Thanks
0
Comment
Question by:4fingers
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
lomo74 earned 2000 total points
ID: 35432578
you have to use dual interfaces, i.e. interfaces that support both early binding and late binding through IDispatch.
to do so, you have to implement IDispatch.
scripting languages (such as javascript or vbscript) discover your interface's capabilities (methods, properties and events) through IDispatch.
0
 
LVL 8

Expert Comment

by:lomo74
ID: 35432605
for a brief introduction to early binding and late binding read here:
http://support.microsoft.com/kb/245115/en-us
0
 
LVL 1

Author Closing Comment

by:4fingers
ID: 35434084
I decided to create a new ATL project and I made sure "Support COM+ 1.0" was checked. Then when I came to creating a new class I enssured the "ATL Simple Object Wizard" had the "Interface" set to "Dual".
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question