使用Visual Basic .NET调用非托管代码 [英] Calling unmanaged code with Visual Basic .NET
问题描述
大家好,
我需要教程,一个完整的导师来指导如何在VB中使用非托管代码。现在我有一个设备的源代码,用于编写C&C ++ I guest,基于依赖步行器。
任何人都可以为我提供链接?我在1个月左右就遇到了这个项目。已经在互联网上搜索但找不到任何内容。
如果有人知道如何使用非托管代码对设备进行编程,请教我高手..非常感谢您的好意
***编辑:
文件作为名称exampleA.dll发送,但是当我尝试添加引用时进入VB.Net,它得到错误无效的程序集或COM组件。当我复制到system32和regsvr32时,无法找到指定模块的事件,它存在于system32文件夹中
你无法添加对它的引用。 DLL因为它不是基于.NET或COM的库。这是一个标准的C库,要求您使用托管代码中的P / Invoke来调用这些函数。
我当然希望你有关于.DLL的文档和它导出的函数是因为没有它,你就没有希望P /调用该库中的函数。
即使示例是在C#中,本教程 [ ^ ]对你要做的事情非常有帮助。
另见本教程 [ ^ ]。
除了解决方案1和解决方案2:
P / Invoke的基础知识在这里解释:<一个 href =http://en.wikipedia.org/wiki/P/Invoke> http://en.wikipedia.org/wiki/P/Invoke [ ^ ]。
这个旧的Microsoft教程尽管如此: http://msdn.microsoft.com/en -us / library / aa288468%28v = vs.71%29.aspx [ ^ ]。
此CodeProject文章也很有用: Essential P / Invoke [ ^ ]。
-SA
Hi all,
I need tutorial, a complete tutor to guide on how to use unmanaged code with VB. Right now I have a source code for a device which writing on C & C++ I guest, based from dependency walker.
Anyone can provide me link for this? I've been stuck with this project around 1 month. Already search on Internet but cannot find any.
If someone know how to program a device from unmanaged code, kindly teach me master.. Really appreciate your kindness
*** Edited:
The file was send as a name exampleA.dll but when I try to add reference into VB.Net, it got error not valid assembly or COM component. When I copy to system32 and regsvr32, it failed that specified module cannot be found event it exist in the system32 folder
You can't add a reference to the .DLL because it's not a .NET or COM-based library. It's a standard C library that requires you to use P/Invoke from your managed code to call those functions.
I sure hope you have the documentation on that .DLL and the functions it exports because, without it, you have no hope of P/Invoking the functions in that library.
Even though the examples are in C#, this tutorial[^] will be very helpful to what you are trying to do.
Also see this tutorial[^].
In addition to Solution 1 and Solution 2:
The basics of P/Invoke are explained here: http://en.wikipedia.org/wiki/P/Invoke[^].
This old Microsoft tutorial is nevertheless quite actual: http://msdn.microsoft.com/en-us/library/aa288468%28v=vs.71%29.aspx[^].
This CodeProject article can also be useful: Essential P/Invoke[^].
—SA
这篇关于使用Visual Basic .NET调用非托管代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!