如何在VB6中创建标准DLL? [英] How can I create a standard DLL in VB6?

查看:260
本文介绍了如何在VB6中创建标准DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TL:DR; 如何将VB6模块文件编译成可以跨多个VB6应用程序使用的标准DLL?



我的任务是支持使用VB6编写的多个遗留应用程序。



所有这些应用程序都使用我雇主构建的硬件。在我为雇主工作之前,他已将为该项目开发一个DLL的工作外包给一个不再能够支持它的公司,因为他们的个人工作最近退出,没有其他人能够弄清楚



我的雇主最近升级了我们的硬件,更糟糕的是,提供给我们的公司的DLL不再有用了。 / p>

进一步加剧了发布给我们的硬件的公司并没有向我们发布一个能够运行的DLL文件VB6。



现在我要创建一个DLL文件( NOT 一个设备驱动程序)促进新(和希望的旧设备)与VB6应用程序之间的通信。



我对VB6的了解至多是有限的。我大都熟悉.NET,并且在.Net中创建DLL方面已经取得了很大的成功,但是当涉及到VB6时,我知道得足够了。我在这里进入未知的领域。



我很熟悉 HID.dll SetupAPI.dll P /调用和结构使这项工作是必要的,我甚至幸运地绊倒了这个,它有一个VB6代码的工作位,它有助于读取/写入连接到系统的HID。我测试了这个(有一点麻烦),它在我们的设备开箱即用。但是这并不能帮助我,因为我不能将模块编译成一个DLL文件(更不用说在VB6中找出事件和其他事情的卡车,但是我已经超越了自己)。



我已经阅读尝试了几种不同的方法,虽然他们证明是有希望的,但他们没有



Google还淹没了我很多红色的鲱鱼,一般来说都不是很有帮助。



如果有必要,我甚至可以用C / C ++编写它(虽然我宁愿不是有其他方式)。



那么我是试图做可能?有没有人可以直接介绍一下这种事情吗?



编辑1:



要说明一点,当我说他们不工作时,我的意思是在第一个链接的情况下,该程序仍然找不到该功能(有一个错误消息,如功能入口点未找到),而在第二种情况下,我试图调用函数(没有乐趣)时一直重复地收到内存写入错误。

解决方案

p> 这里是一个链接到一个标准DLL的方法,那看起来比您发布的链接更直接。我可以说,如果Mike Strong(strongm)发布代码,它也可以工作。您可能想看看它。



但是,如果可以使用COM可能会更好:更容易设置(显然),它也是具有一些标准的功能,用于跟踪VB6内置的对象接口。例如,当您使用 TypeOf 关键字时,VB6实际上会对对象的QueryInterface方法进行内部调用,该方法保证作为COM的规则之一存在(而且,如果您在引用标准DLL对象时使用关键字,则会收到错误)。



VB6通过将类的Instancing属性设置为GlobalMultiUse来执行静态类。警告:静态关键字在VB6中有完全不同的含义:静态局部变量的值在方法调用之间持续存在。


TL:DR; How can I compile a VB6 module file into a standard DLL which I can use across multiple VB6 applications?

I am tasked with the support of multiple legacy applications written in VB6.

All of these applications make use of piece of hardware constructed by my employer. Before I came on to work for my employer, he had outsourced the work of developing a DLL for the project to a company that is no longer capable of supporting it since the individual working for THEM recently quit and no one else is capable of figuring it out.

My employer has recently upgraded our hardware, so even worse - the DLL that Company furnished us with is no longer useful either.

Further exacerbated by the fact that the company who released to us the NEW hardware did not release to us a DLL file which is capable of running in VB6.

It now falls to me to create a DLL file ( NOT a device driver ) which is capable of facilitating communications between the new ( and hopefully the old ) devices and VB6 applications.

My knowledge of VB6 is... limited, at best. I am mostly familiar with .Net and have had much success in creating DLLs in .Net, but when it comes to VB6, I know enough to get by. I'm entering into uncharted territory here.

I'm well acquainted with the HID.dll and the SetupAPI.dll P/Invokes and structs necessary to make this work, and I was even fortunate enough to stumble upon this, which had a working bit of VB6 code which facilitates read/writing to/from HIDs connected to the system. I tested this and ( with a bit of fidgeting ) it worked for our device out of the box. But that doesn't help me because I can't compile the module into a DLL file ( let alone figuring out events in VB6 and a truck load of other things, but I'm getting ahead of myself ).

I've read and tried a few different methods and while they proved promising, they didn't work.

Google has also inundated me with a lot of red herrings and been in general not very helpful.

If necessary, I would even write it in C/C++ ( though I'd rather not if there is some other way ).

So is what I am trying to do possible? Can someone direct me to some step-by-step for this sort of thing?

EDIT 1 :

To expound a bit, when I say that "they didn't work", what I mean is that in the case of the first link, the program still failed to find the function ( with an error message like "Function entry point not found" ) and in the second case I consistently and repeatedly received a memory write error when trying to call the function ( not fun ).

解决方案

Here's a link to a way to do a standard DLL, that looks more straightforward than the links you've posted. I can say that if Mike Strong ("strongm") posts code, it works, too. You might want to have a look at it.

However, it's probably better to use COM if you're able: it's easier to set up (obviously) and it also has some standard capabilities for keeping track of the object's interface, that are built into VB6. For example, when you use the TypeOf keyword, VB6 actually makes an internal call to the object's QueryInterface method, which is guaranteed to exist as one of the rules of COM (and, if you use the keyword on a reference to a standard DLL object you'll get an error).

VB6 does "static" classes by setting the class's Instancing property to GlobalMultiUse. Warning: the "static" keyword has an entirely different meaning in VB6: static local variables' values persist between method calls.

这篇关于如何在VB6中创建标准DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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