在c#代码中导入DLL函数
Importing DLL functions in c# code
我有一个DLL,我想在我的c#代码中使用它的函数以下是该DLL的函数:
extern "C"
{
__declspec(dllimport)
const char* __stdcall ZAJsonRequestA(const char *szReq);
__declspec(dllimport)
const wchar_t* __stdcall ZAJsonRequestW(const wchar_t *szReq);
__declspec(dllimport)
const BSTR __stdcall ZAJsonRequestBSTR(BSTR sReq);
}
谁能告诉我如何在c#项目中使用它,因为这个dll似乎是在其他语言?
请查看下面关于Code Project的文章以获得更深入的解释
链接文章中的一个小示例如下
调用一个函数,输入methodName
int __declspec(dllexport) methodName(int b)
{
return b;
}
在c#
中包含包含上述方法的类库(MethodNameLibrary.dll),如下所示class Program
{
[DllImport(@"c:MethodNameLibrary.dll")]
private static extern int methodName(int b);
static void Main(string[] args)
{
Console.WriteLine(methodName(3));
}
}
使用DllImport和MarshalAs属性
相关文章:
- Visual c ++,使用字符串引用/指针调用 dll 函数
- 在 Microsoft Access SQL 中调用自定义 DLL 函数时传递的内存地址无效
- 调用 "project" 函数和调用 DLL 函数之间的区别
- 代码在 msvcrt .dll函数上设置断点失败
- VB.NET DLL中的C++DLL函数复制
- 在python-ctypes中声明变量并传递给dll函数
- 从 Python 调用 Windows DLL 函数时出错
- 调用 dll 函数时"Run-Time Check Failure #0 - The value of ESP"
- 列出 C# 中的 non-.NET DLL 函数
- 基本 DLL 函数
- 如何在不可修改的源代码中使用 DLL 函数?
- 对需要双精度数组和结构作为输入C++ DLL 函数的 C# 调用
- WScript.CreateObject 在调用 C++ COM dll 函数时返回空
- 如何在 lua cpp 模块中调用托管 c++ dll 函数
- 测试C++ DLL 函数
- 从 C# GUI 将 char * 参数传递给C++ dll 函数
- 使用指针调用C++ DLL 函数
- 在C++中导入 DLL 函数
- #VALUE!在 64 位 Excel 中调用 DLL 函数 (C++) 时
- 如何从 UWP 应用调用"libheif.dll"函数