如何使用java / vb脚本在自定义ActiveX dll中调用方法 [英] How do I call a method in a custom ActiveX dll using java/vb script

查看:252
本文介绍了如何使用java / vb脚本在自定义ActiveX dll中调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用VB6创建了一个ActiveX DLL,并使用Package&部署向导导致了cab文件和演示HTML页面。

I have created an ActiveX dll using VB6 and packaged it using the Package & Deployment Wizard which has resulted in a cab file and a demo HTML page.

此ActiveX dll包含一个simgle方法,返回一个字符串,不接受任何参数。

This ActiveX dll contains a simgle method that returns a string and accepts no arguments.

有一个是当我调用该方法时,我总是得到一个对象不支持此属性或方法错误。但是, 支持我打电话的方法。

The trouble I'm having is that when I call the method I always get a "Object does not support this property or method" error. But it does support the method I'm calling.

我想要实现的是让用户去一个网页,里面有一些java或vb脚本,它调用我的ActiveX中的方法,并获取字符串返回值。该DLL旨在称为客户端。

What I'm trying to achieve is for users to go to a web page that has some java or vb script in it that calls method in my ActiveX and gets the string value returned. The DLL is intended to be called client side.

我的测试网页如下:

<html>
<head>
    <title>SaveClipboardImage.CAB</title>
    <object id="Class1" classid="CLSID:" codebase="SaveClipboardImage.CAB#version=1,0,0,0"></object>
    <script type="text/javascript">
            function displaymessage()
            {
                try
                {
                var filename;

                filename = Class1.SaveClipboardToImage();

                alert(filename);
                }
                catch(e)
                {
                    alert(e.message);
                }               
            }
    </script>
</head>
<body>      
    <input type="BUTTON" onclick="displaymessage()" value="preview" />
</body>
</html>

我显然做错了,但我不知道是什么。
我必须在VB6项目中对类进行特殊处理,以便我可以访问该方法?
我不正确地调用DLL?

I'm obviously doing something wrong, but I don't know what. Do I have to do something special to the class in the VB6 project so I can access the method? Am I calling the DLL incorrectly?

感谢您的帮助。

推荐答案

Javascript对于Class1一无所知。你必须把对象变成javascript。

Javascript knows nothing about Class1. You have to get the object into javascript.

尝试:

        function displaymessage()
        {
            try
            {
                var filename;
                var class1 = document.getElementById("Class1");
                filename = class1.SaveClipboardToImage();

                alert(filename);
            }
            catch(e)
            {
                alert(e.message);
            }                       
        }

这篇关于如何使用java / vb脚本在自定义ActiveX dll中调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆