各位大侠,我用VC++ 6.0写了一个DLL库,里面包含一个Class,该Class有几个方法。想在C#中调用该DLL库,使用该Class的方法不知道该如何操作,请高手们指点指点。以下是VC++写的DLL库里面的定义
================================
// VCEdll.h : main header file for the VCEDLL DLL
//#if !defined(AFX_VCEDLL_H__8187D002_DF65_4336_A057_D96A5014F96A__INCLUDED_)
#define AFX_VCEDLL_H__8187D002_DF65_4336_A057_D96A5014F96A__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#ifdef _CLASSINDLL 
    #define CLASSINDLL_CLASS_DECL _declspec(dllexport) 
#else 
    #define CLASSINDLL_CLASS_DECL _declspec(dllimport) 
#endif class CLASSINDLL_CLASS_DECL CVCEdllApp
{
public:
CVCEdllApp();
virtual ~CVCEdllApp(); public:
int  VCEsOpen(void);  //打开设备
int  VCEsAlive(void); //每隔5s调用一次

};
///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_VCEDLL_H__8187D002_DF65_4336_A057_D96A5014F96A__INCLUDED_)

解决方案 »

  1.   

    C#调用VC++ 6.0编写的函数倒是简单,可以按照如下的方法,不过Class怎么办???[DllImport("ex.dll", EntryPoint = "method")]
    public static extern void method(int a);
    //其中ex.dll为C++DLL名,method为函数名,  这里的int a为C++中方法的参数转换。//例:C++DLL名:Interface.dll,函数为voidCopMemFree(void *vp);
    //调用格式为:
    [DllImport("Interface.dll", EntryPoint = "CopMemFree")]
     public static extern void CopMemFree(IntPtr vp);
      

  2.   

    也就是用C++的dll中的函数再次封装class?
      

  3.   

    c# 就算了,老老实施用vc写个适配器程序,将导出函数中做个中转,
    不过VC.net应该是有办法的实现你的要求的