Link to home
Start Free TrialLog in
Avatar of 4fingers
4fingers

asked on

How do I create a DLL to interface with JavaScript

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
ASKER CERTIFIED SOLUTION
Avatar of lomo74
lomo74
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
for a brief introduction to early binding and late binding read here:
http://support.microsoft.com/kb/245115/en-us
Avatar of 4fingers
4fingers

ASKER

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".