如何在VB.NET或C#中使用C++API
How to use C++ API in VB.NET or C#
我需要在.NET中嵌入一个用C++编写的API,指纹设备使用该API到.NET应用程序中。
我尝试了VB.NET和C#这两种语言,但仍然无法理解它给我带来的问题;
在DLL中找不到入口点。
这意味着它访问DLL,但问题是什么,你能告诉我吗?
这是示例代码:
internal static class UnsafeNativeMethods
{
const string _dllLocation = "ABCAPI.dll";
[DllImport(_dllLocation, EntryPoint = "ABCFunc", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl )]
public static extern bool ABCFunc();
}
[System.Runtime.InteropServices.DllImport("ABCAPI.dll", SetLastError = true)]
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
public static extern bool ABCFunc();
谢谢@Hans Passant我做了一个研究和使用"dumpbin/Exports mydllname.dll"找到函数的实际声明,这最终对我有效。
internal static class UnsafeNativeMethods {
const string _dllLocation = "ABCAPI.dll";
[DllImport(_dllLocation, EntryPoint = "_ABCFunc@4", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.ThisCall )]
public static extern bool ABCFunc();
}
而且效果很好,谢谢你的建议。
相关文章:
- 用于访问容器<T>数据成员的正确 API
- 如何使用Luacneneneba API正确读取字符串和表参数
- C++MySQL C api用户输入行
- 如何使用 AWS Transcribe C++ API 中的'StartTranscriptionJobRequest'?
- 将std::string传递给WriteConsole API
- EvtExportLogneneneba API正在将远程计算机的事件日志保存到远程PC本身.如何将其保存到主机
- 在gtest.中使用fff.h模拟系统API
- 有没有任务栏API可以立即应用注册表更改
- C++win32 API创建多个类似视口的窗口
- 使用libcurl提交批量url的正确BING Api POST url是什么
- 如何将真正的字符串从python c-api转换为python脚本
- 使用Qt框架在c ++类中创建API调用
- Libreoffice API (UNO):需要更改用户的 xTextField 文本
- 如何在 64 位 vb.net Windows 应用程序中引用 32 位 dll
- 使用 WIN32 API (C/C++) 对特定树视图项进行着色
- 使用 Python Extension API 包装复杂C++类
- 如何使用 samtools C API 构建一个简单的主.cpp文件
- 第三方 API 中的编译错误 - Visual Studio
- 如何在VB.NET或C#中使用C++API
- 如何在VB.net中使用Windows电源管理API