各位大侠,我用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_)
================================
// 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_)
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);
不过VC.net应该是有办法的实现你的要求的