2010-09-23 197 views

回答

4

您可能希望为该类创建托管C++包装器,并使用/ clr(公共语言运行时支持)对其进行编译,然后您可以在C#中使用它。 你可能也想看看PInvoke。

1

的CLR不使用本地C++类的直接支持,它更静态方法通过的PInvoke或COM接口调用通过COM互操作使用。所以需要某种C++包装器。

0

例如像这样:

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 
    ); 
} 

创建你的小包装,进口所需的功能和呼叫