从C#调用非托管C++类DLL#
答
您可能希望为该类创建托管C++包装器,并使用/ clr(公共语言运行时支持)对其进行编译,然后您可以在C#中使用它。 你可能也想看看PInvoke。
答
的CLR不使用本地C++类的直接支持,它更静态方法通过的PInvoke或COM接口调用通过COM互操作使用。所以需要某种C++包装器。
答
例如像这样:
public unsafe class CppFunctionImport
{
[DllImport("ImageProcessingCpp.dll", EntryPoint = "PerformMovingAverage", ExactSpelling = true, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]//!-!
public static extern void PerformMovingAverage
(
ref byte *image,
int width,
int height,
int stride,
int kernelSize
);
}
创建你的小包装,进口所需的功能和呼叫
我会用这对C的dll但C++肯定不... – jdehaan 2010-09-23 07:27:52