Create ActiveX object from CLSID

2,112 views
Skip to first unread message

Matt Lind

unread,
Sep 16, 2009, 7:17:02 PM9/16/09
to soft...@listproc.autodesk.com
Anybody know a quick way of taking a CLSID provided as a string and creating an ActiveX object it represents?  Preferrably in JScript.
 
thanks.
 
Matt
 

Michael Buss

unread,
Sep 17, 2009, 12:19:33 AM9/17/09
to soft...@listproc.autodesk.com
One way I know, is to read the ProgID from the registry:

var shellObj = new ActiveXObject("WScript.Shell");
var clsid = "F5078F32-C551-11D3-89B9-0000F81FE221";
var progid =
shellObj.RegRead("HKEY_CLASSES_ROOT\\CLSID\\{"+clsid+"}\\ProgID\\");
var xmlDoc = new ActiveXObject(progid);


Michael

Marc-Andre Belzile

unread,
Sep 17, 2009, 8:44:00 AM9/17/09
to soft...@listproc.autodesk.com
We have a wrapper in XSIFactory to create activeX objects from a prog ID (i.e. string):

XSIFactory.CreateActiveXObject

-mab

winmail.dat

Marc-Andre Belzile

unread,
Sep 17, 2009, 8:46:24 AM9/17/09
to soft...@listproc.autodesk.com
GUID string is also supported.
winmail.dat

Matt Lind

unread,
Sep 17, 2009, 7:33:37 PM9/17/09
to soft...@listproc.autodesk.com
This works. Could you point me to some documentation where you found
how to do this?

So far I've used 'find' in regedit to locate the ActiveX control and the
string needed to generate it using 'new ActiveXObject()', but would be
nice if I could do the reverse lookup automatically and ditch CLSIDs
altogether.

Thank you.


Matt


> -----Original Message-----
> From: softimag...@listproc.autodesk.com
> [mailto:softimag...@listproc.autodesk.com] On Behalf Of
> Michael Buss
> Sent: Wednesday, September 16, 2009 9:20 PM
> To: soft...@listproc.autodesk.com
> Subject: Re: Create ActiveX object from CLSID
>

Matt Lind

unread,
Sep 17, 2009, 7:38:50 PM9/17/09
to soft...@listproc.autodesk.com
I get a string returned from some of the APIs I'm using like:

"<object {clsid:xxxx-xxxx-xxx-xxx-xxx}, attributeName="", ....>

I need to convert the CLSID into the ActiveX object. I have tried:

var oControl = XSIFactory.CreateActiveXObject(
"clsid:xxxx-xxxx-xxxx" );
- and -
var oControl = XSIFactory.CreateActiveXObject( "xxxx-xxxx-xxxx"
);

LogMessage( "Class: " + Application.ClassName( oControl ) );

but the returned control doesn't play nice with Application.ClassName().
No exceptions thrown, but nothing is returned either. So I have no idea
what was returned.


Matt

Luc-Eric Rousseau

unread,
Sep 17, 2009, 8:33:02 PM9/17/09
to soft...@listproc.autodesk.com
Did you try the the guid string in braces? That's the standard notation. {abdb-....ab}

Luc-Eric Rousseau
Team Leader, Softimage

Michael Buss

unread,
Sep 17, 2009, 9:09:21 PM9/17/09
to soft...@listproc.autodesk.com
@Matt:

It works when you remove the "clsid:"-part from the string, but leave
the brackets:

var oControl = XSIFactory.CreateActiveXObject("{xxxx-xxxx-xxxx}");

Michael Buss

unread,
Sep 17, 2009, 9:25:43 PM9/17/09
to soft...@listproc.autodesk.com
WScript.Shell is part of Windows Scripting Host and can be used to
access the Windows shell. It also has some basic methods to deal with
the registry.

The documentation can be found here:

http://msdn.microsoft.com/en-us/library/aew9yb99(VS.85).aspx

Reply all
Reply to author
Forward
0 new messages