繁体   English   中英

在C#中调用vc ++ dll

[英]Call vc++ dll in c#

我在vc ++中有一个dll和相应的头文件(.h文件),现在我必须在c#中调用此dll。 我对调用约定一无所知。

在头文件中,有一个函数原型,例如:

typedef void CBOnStop_VC( int nFGHandle, unsigned int nChannel, void* pClientData );

现在,我想在c#中调用此函数。

任何想法?

您可以使用这些步骤

1. compile your classe with the /clr switch

#include "NativeType.h"

public ref class ManagedType
{
     NativeType*   NativePtr; 

public:
     ManagedType() : NativePtr(new NativeType()) {}
     ~ManagedType() { delete NativePtr; }

     void ManagedMethod()
      { NativePtr->NativeMethod(); } 
}; 

2.Add a reference to your ManagedType assembly

ManagedType mt = new ManagedType();
mt.ManagedMethod();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM