Results 1 to 12 of 12

Thread: DLL call from JavaScript

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    8

    DLL call from JavaScript

    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???

    Thanks,
    Dimitris

  2. #2
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    *loads*

    Do you have JavaScript as a shell scripting language (running through WSH, presumably)?
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  3. #3
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    javascript isin't really designed to be calling DLL's. Why don't you use VBS?

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  4. #4
    Hyperactive Member thinktank2's Avatar
    Join Date
    Nov 2001
    Location
    Arctic
    Posts
    272

    Re: DLL call from JavaScript

    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???

    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 ??

  5. #5
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    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.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  6. #6
    Hyperactive Member thinktank2's Avatar
    Join Date
    Nov 2001
    Location
    Arctic
    Posts
    272
    Ciber are u cussing me ??

    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

  7. #7
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    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.

    Perhaps he thinks JScript and JavaScript are the same. If so, he is more ignorant than I thought.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  8. #8
    Hyperactive Member thinktank2's Avatar
    Join Date
    Nov 2001
    Location
    Arctic
    Posts
    272
    Well, he is confused but for the fact that Microsoft IE uses Jscript even though you explcitly mention Javascript as ur language.

  9. #9
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    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.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  10. #10
    Hyperactive Member thinktank2's Avatar
    Join Date
    Nov 2001
    Location
    Arctic
    Posts
    272
    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/de...x/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.

  11. #11

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    8
    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.

    Dimitris
    Last edited by spanosdm; Jan 8th, 2002 at 07:16 AM.

  12. #12
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    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.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width