PDA

Click to See Complete Forum and Search --> : DLL call from JavaScript


spanosdm
Jan 7th, 2002, 05:33 AM
Hi all,
I use
var <myVar> = new ActiveXObject("<ProjectName>.<ClassName>");
But it doesn't seem to work. The very same DLL works perfectly when called from ASP
Set <myVar>=CreateObject("<ProjectName>.<ClassName>")
The code is so similar, I don't understand why it does not work from javaScript... Any ideas???
:confused:
Thanks,
Dimitris

CiberTHuG
Jan 7th, 2002, 11:00 AM
*loads*

Do you have JavaScript as a shell scripting language (running through WSH, presumably)?

sail3005
Jan 7th, 2002, 11:01 AM
javascript isin't really designed to be calling DLL's. Why don't you use VBS?

thinktank2
Jan 7th, 2002, 02:37 PM
Originally posted by spanosdm
Hi all,
I use
var <myVar> = new ActiveXObject("<ProjectName>.<ClassName>");
But it doesn't seem to work. The very same DLL works perfectly when called from ASP
Set <myVar>=CreateObject("<ProjectName>.<ClassName>")
The code is so similar, I don't understand why it does not work from javaScript... Any ideas???
:confused:
Thanks,
Dimitris

Are u using it from an ASP page or just a html page with some Jscript thrown in ??

To create objects within the ASP context you have to use
Server.CreateObject. It is an ASP thingo and as such available in all the supporting asp scripting languages including jscript.

Note: The plain "CreateObject" Method is specific to vbscript and
ActivexObject method is specific to Jscript. When ASP comes in to picture and u want to run an object in the context of an ASP Page u have to use Server.CreateObject.

Anyways what's the Activex dll's name ??

CiberTHuG
Jan 7th, 2002, 03:08 PM
Okay, I don't want to see anyone else respond to this as though it is a serious problem. The fact of the matter is this:

YOU CAN'T CALLED ACTIVEX DLLS FROM JAVASCRIPT!!! THIS POSES A SECURITY RISK!!!

You can create ActiveX controls that the web user will have to download.

Further, I'm not giving this speech again, but I have to sum up.

The ASP is run on the server side. The JavaScript embedded in the page is run on the client side. If that doesn't make sense, then you need to learn about computers.

I only wish I was a teacher.

thinktank2
Jan 7th, 2002, 03:23 PM
Ciber are u cussing me ?? :D

We are talking about JScript (Microsoft's version of Javascript).
Did u see my previous posts...every word I mentioned is about Jscript. It's not javascript.

Whether it poses a risk or not u can call activex dll from Jscript.
That is why they made a function called ActiveXObject.

Jscript can make use of Activex dll at the server side. Infact this is how u can use ADO to access database using Jscript at the server side. Now.. I am the teacher ... my dear student ;)

CiberTHuG
Jan 7th, 2002, 03:27 PM
Tank, I'm not cursing you, but while you may be talking about JScript, this is a JavaScript forum, and the thread starter clearly mentions JavaScript several times. :eek:

Perhaps he thinks JScript and JavaScript are the same. If so, he is more ignorant than I thought.

thinktank2
Jan 7th, 2002, 03:31 PM
Well, he is confused but for the fact that Microsoft IE uses Jscript even though you explcitly mention Javascript as ur language.

CiberTHuG
Jan 7th, 2002, 04:23 PM
Wow... well... if IE doesn't support JavaScript, and if it allows client-side JScripts to call on ActiveX DLLs, then there are two more reason to not use IE.

One, JScript is just a knock-off. And I don't expect it to be terribly open.

Two, having the unfettered ability to call on DLLs poses a massive security risk.

Good thing I wasn't a fan of IE to begin with.

thinktank2
Jan 7th, 2002, 05:42 PM
IE does support Javascript but it also adds it's own baggage {What u will call proprietary extensions to Javascript }.
JScript is a knock off, but sorry it wasn't meant to be open.
You can't expect such a thing from Microsoft.

U can't call any activex control u think. Only those that are marked safe by the Activex Developer. see

http://msdn.microsoft.com/library/default.asp?url=/workshop/components/activex/security.asp

for more details.

As a user, u don't need to take a peek at IE. But as a developer if you are Ignoring IE and not making IE compliant code u are going to miss an entire bunch of audience. I don't believe that's what your employers want.

spanosdm
Jan 8th, 2002, 01:53 AM
Hi again,
I use jS from an ASP page.

To make you understand what I want to do, I made a DLL from Visual Basic called CardProject.dll, and through this DLL I have to check if the user has a smart card in the smart card reader and if so, read a code from the card. Obviously, this has to be done client-side so I really need to call the DLL from the client's machine.

I tested the DLL from ASP and it works fine, but the problem is that since ASP runs server-side, the script works only if reader and the card is on the server, which is not what I want to do.

Travis, I *am* a teacher at highschool. ;) Peace. And it's the first time someone calls me ignorant in a forum. If I knew everything, would I be here? After your suggestion, I put the following code
var MyCard = new ActiveXObject("CardProject.CardClass");
MyCard.ReadFromTheCard(SmartCardCode, 40, 5);
in an external .js file, I executed it from Windows Explorer and the function works. I can tell because there are leds flashing when the reader is reading. The very same code does not work when placed inside the asp/html page, or when I use the <SCRIPT LANGUAGE="JavaScript" src="<file>.js"></SCRIPT> command to call the external file. :eek:

Dimitris

CiberTHuG
Jan 8th, 2002, 08:48 AM
Originally posted by thinktank2
As a user, u don't need to take a peek at IE. But as a developer if you are Ignoring IE and not making IE compliant code u are going to miss an entire bunch of audience. I don't believe that's what your employers want.

I'm not ignoring any particular browser, and I'm never going to make some particular browser-compliant code. I will make code that is compliant with industry standards. If your browser doesn't follow the industry standards, well then I don't care.

Since all browsers claim to support JavaScript, then I have no choice but to use JavaScript. I am a little upset by the chaos of trying to define any parts of the language not covered by the W3C and ECMA. For example: setInterval and setTimeout. These are beyond the scope of ECMA-262 currently. The window object is beyond the scope of the W3C DOM. And I'm just not finding the level of documentation at NC that I would hope to find from the creators and curators of a language.

Maybe I should check at Sun, but I digress.

spanosdm, as far as I know, JavaScript won't call client-side DLLs. JScript may, and Tank may be right in that IE does not support JavaScript. If this is the case, so be it. As to why your client-side script works when in a static HTML page but not when it is reffered to in a link or in an ASP, I don't know, and couldn't figure out without looking at the entire page.

But, JScript is not something I care to know anything about. Aside from that, are you using HTTPS? If not you are underminding the security.