如何在用C ++ DLL编写的C#中调用函数 [英] how to call function in c# written in c++ dll

查看:80
本文介绍了如何在用C ++ DLL编写的C#中调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有xyz.dll和两个头文件xyz.hpp和ErrorCode.h
在xyz.hpp

I have xyz.dll and two header file xyz.hpp and ErrorCode.h
In xyz.hpp

#define  FC3_PR_VERSION   "Version" 
typedef void *  FC3_t 
typedef FC3_t  FC3Template_t  
typedef FC3_t  FC3Encode_t  
typedef FC3_t  FC3Match_t  
typedef void DRMAPI  ProgressCallBack_t
(int nPercentCompleted, void *const pUserData) 

abcErrorCode_t FC3Initialize (const char *szReserved) 
abcErrorCode_t FC3Uninitialize (void) 
abcErrorCode_t FC3CreateTemplate (FC3Template_t *const pTemplateHandle) 
abcErrorCode_t FC3CreateEncoder (FC3Encode_t *const pEncodeHandle) 
abcErrorCode_t FC3Encode (const FC3Encode_t hEncodeHandle, const BITMAPINFOHEADER *const pBitmapData, const size_t nBitmapSize, const FC3Template_t hTemplate) 
abcErrorCode_t FC3CreateMatcher (FC3Match_t *const pMatchHandle) 
abcErrorCode_t FC3DestroyHandle (FC3_t *const pHandle)
abcErrorCode_t FC3Match (const FC3Match_t hMatchHandle, const FC3Template_t hTemplate1, const FC3Template_t hTemplate2, double *const pdScore)  


并在ErrorCode.h中


and in ErrorCode.h

#define FPC_SUCCESS   0
#define  FPC_ERROR_INITIALIZED   -1 
#define  FPC_ERROR_NOT_INITIALIZED   -2 
#define  FPC_ERROR_NO_LICENCE   -3 
#define  FPC_ERROR_NO_CB_ONEND   -4 
#define  FPC_ERROR_NO_CB_ONERROR   -5 
#define  FPC_ERROR_CODING_LOGGED   -6 
#define  FPC_ERROR_BITMAP_PTR   -10 
#define  FPC_ERROR_BITMAP_COMPRESSION   -31 
#define  FPC_ERROR_BITMAP_HEADERSIZE   -32 
#define  FPC_ERROR_BITMAP_UNEXPECTED_FILEHEADER   -36 

typedef long abcErrorCode_t 


我想在c#中调用这些函数(帮助我).


I want to call these functions in c#(help me).

推荐答案

有人称它为p.invoke.或者,您可以将其设置为COM dll,然后通过COM进行调用.
It''s called p.invoke as someone said. Or you can make it a COM dll and call it via COM.


这篇关于如何在用C ++ DLL编写的C#中调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆