有没有导出功能(不是一个类)在VB6? [英] Is there anyway to export a function (not a class) in VB6?

查看:199
本文介绍了有没有导出功能(不是一个类)在VB6?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Visual Basic 6中创建一个ActiveX DLL,我想从中调用一些公共函数。我将仅从VB6调用此DLL。但是,似乎只有类才能导出。有解决办法吗?

I want to create an ActiveX DLL from Visual Basic 6 from which I would like to call some public functions. I will call this DLL only from VB6. However, it seems that only classes get exported. Is there any workaround?

我知道有一种使用标准WINAPI功能从VB6创建DLL的方法。这不是我想要的,因为我必须键入数千个Declare指令,我会失去动态链接,所以我不需要在更改DLL时重新编译应用程序。

I know there is a way to create DLLs from VB6 with standard WINAPI functions. This is not what I want, because I would have to type thousands of Declare instructions, and I would lose the dynamic linking so I don't need to recompile applications when changing the DLL.

我会说出我的问题,以防万一有更好的想法。我有一堆相对较大的项目,每个都有自己的代码,然后我有很多通用代码,用于多个项目。将每个文件添加到每个新项目是一个烦恼,并且不得不重新编译每个文件的每个小的更改。所以我想到创建一个DLL,所以我只是添加引用,当我开始一个新的项目,而不必担心重新编译(至少是微小的变化),但我发现只有类已被导出

I will state my problem just in case anyone has a better idea. I've got a bunch of relatively big projects, each with its own code, and then I have a lot of "Generic" code which is used in several projects. It's an annoyance to add every file to each new project, and having to recompile all of them for each minor change. So I thought of creating a DLL, so I would just "Add reference" when I begin a new project, and don't have to worry anymore about recompiling (at least for minor changes) but I raged when discovered that only classes got exported.

我不介意重新组织课程中的代码,但这是一个压倒性的任务:有大约10年的3-4人代码,所以这不是东西我可以做一夜。

I wouldn't mind to reorganize the code in classes, but it's an overwhelming task: there are some 10 years of 3-4 people code, so it's not something I can do overnight.

推荐答案

是的,很容易。


  1. 将所有实用程序例程放在DLL中的特殊类中。

  2. 设置将这些类的属性实例化为 GlobalMultiUse

  3. 构建DLL。

  4. 在您的客户端项目(引用DLL)中,您现在可以将函数和子例程调用为如果他们在该项目的模块中。您不需要创建任何对象。

  1. Put all the utility routines in special classes in the DLL.
  2. Set the Instancing property of those classes as GlobalMultiUse.
  3. Build the DLL.
  4. In your client project (with a reference to the DLL) you will now be able to call the functions and subroutines as if they were in a module in that project. You won't need to create any objects.

您可以在 VB6手册

这篇关于有没有导出功能(不是一个类)在VB6?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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