我有一个使用 C# 的 ASP.NET 网站,我想从非托管 C/C++ DLL 调用函数。我该怎么做?
Mendokusai
问问题
5927 次
3 回答
10
创建一个非托管 dll:
extern "C" __declspec(dllexport) __cdecl int sum(int a,int b); ---->
创建一个命名空间/类到 DllImport 上面的 DLL
using System.Runtime.InteropServices; namespace ImportDLL { public class importdll { public importdll() { } DllImport("mysum.dll", EntryPoint="sum", ExactSpelling=false, CallingConvention = CallingConvention.Cdecl)] public extern int myfun(int a, int b); } }
在后面创建一个aspx代码
using ImportDLL; namespace TEST { public int my_result; protected importdll imp = new importdll(); my_result = imp.myfun(1,1); }
于 2009-04-06T01:33:09.937 回答
5
于 2009-04-06T01:31:19.473 回答
0
只需添加pinvoke.net 即可满足您的 Win32 需求。
于 2010-06-03T14:52:43.790 回答