Call C # and C ++ example of a

#ifdef __cplusplus
extern "C" {
#endif
	int  WINAPI cls_init(wchar_t *SystemPath,wchar_t* userID);
	void WINAPI cls_uninit();
	int  WINAPI cls_classify_image_file(wchar_t *szImageFileName);
	int  WINAPI cls_get_classify_result(wchar_t *buffer,int& buffer_len);
#ifdef __cplusplus
}	// extern "C"
#endif

C#

        [DllImport(DLLName, EntryPoint = "cls_get_classify_result", CharSet = CharSet.Unicode)]
        public static extern int _cls_get_classify_result(char[] strBuffer, out int nBufferLen);

use:

 errorCode= _cls_classify_image_file(fileName);
            if (errorCode > 0)
            {
                int nbufferlen = 0;
                errorCode = _cls_get_classify_result(null, out nbufferlen);//第一次获得长度
                if (errorCode == 0)
                {
                    char[] lbresult = new char[nbufferlen];//第二次构造后,再调用一次取值
                    lbresult.Initialize();
                    _cls_get_classify_result(lbresult, out nbufferlen);

The above is a recognition of identified cases.

Guess you like

Origin blog.csdn.net/wlanye/article/details/88886994