dll在VS2010项目中工作正常,但在VS6应用程序中提供访问冲突 [英] dll works fine in a VS2010 project but gives access violations in a VS6 Application

查看:196
本文介绍了dll在VS2010项目中工作正常,但在VS6应用程序中提供访问冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去几个星期我一直在为usb设备创建一个dll,设备自带了自己的dll,我用来在VS2010中创建自己的dll,然后我创建了一个测试应用程序,在2010年使用该dll。得到它工作。它工作得很好,但是我现在需要在VS6项目中使用它,当我使用它,我获得访问违例,我重新创建的VS6中的dll,看看是否会有帮助,它让我进入代码,尽快它得到一行在我的DLL,调用第三方DLL,它导致访问冲突,我刚刚尝试创建一个工厂函数创建一个抽象接口,我的DLL,但我再次获得访问违例。我对dll是新的,完全没有想法,帮助或洞察将非常吝惜...

I have been creating a dll for a usb device over the past few weeks, the device came with its own dll which i used to create my own dll in VS2010, I then created a test application which uses said dll in 2010 to get it working. It works well, however I now need to use it in a VS6 project, when i use it I get access violations, I recreated the dll in VS6 to see if that would help, it allowed me to step into the code, as soon as it gets to a line in my dll that calls the 3rd party dll, it causes an access violation, I have just tried creating a factory function to create a abstract interface to my dll but I again get access violations. I am new to dlls and am completely out of ideas, and help or insight would be greatly appritiated...

推荐答案

你可以得到一个使用更高版本的Visual Studio创建的DLL来使用Visual Studio 6是以通用的方式编码你的DLL,传递的参数和返回到DLL的导出函数。

The way you can get a DLL created with a later version of Visual Studio to work with Visual Studio 6 is to code your DLL in a generic way in terms of parameters passed and returned to the DLL's exported functions.

例如,Windows API描述了某些变量类型。这些类型包括 DWORD LONG BOOL c $ c> DWORD_PTR 等。包括各种字符串指针类型,例如 LPCSTR 。此列表中还包括指向这些各种类型的指针,例如 LPLONG LPBYTE LPVOID 等。

For example, the Windows API describes certain variable types. These types include DWORD, LONG, BOOL, DWORD_PTR, etc. Included are the various string pointer types such as LPCSTR. Also included in this list are pointers to these various types such as LPLONG, LPBYTE, LPVOID etc.

如果你的DLL的导出函数传递或返回一个不是上面的类型,该DLL只能在使用与DLL构建的相同版本的Visual Studio构建的应用程序中安全地使用。

If your DLL's exported functions passes or returns a type that isn't one of the above, then you're stuck -- the DLL can only be used safely in an application that was built with the same version of Visual Studio that the DLL was built with.

例如,如果您传递C ++对象(标准库对象,甚至是你自己的对象),这是一个很大的没有,如果你想要的DLL在几个版本的Visual Studio工作。

For example, if you're passing C++ objects (standard library objects, or even your own objects), that is a big no-no if you want that DLL to work across several versions of Visual Studio.

这篇关于dll在VS2010项目中工作正常,但在VS6应用程序中提供访问冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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