C++结构体
struct BarcodeInfo //条码结构信息
{
char ShowContent[16] ;//条码显示内容
char BarcodeContent[16];//条码内容
};
//动态库LabelPrint.dll,接口如下
int PrintBarCode(BarcodeInfo* pBatchInfo,
BarcodeInfo* pBarcodeinfoArray,//条型码数组
int nSize)//数组大小// 在C#中如果调用PrintBarCode
struct BarcodeInfo //条码结构信息
{
char ShowContent[16] ;//条码显示内容
char BarcodeContent[16];//条码内容
};
//动态库LabelPrint.dll,接口如下
int PrintBarCode(BarcodeInfo* pBatchInfo,
BarcodeInfo* pBarcodeinfoArray,//条型码数组
int nSize)//数组大小// 在C#中如果调用PrintBarCode
http://blog.csdn.net/sunboyljp/article/details/5110639
http://blog.csdn.net/jadeflute/article/details/5684687
public struct BarcodeInfo
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public char[] ShowContent;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public char[] BarcodeContent; };
[DllImport("LabelPrint.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
public static extern int PrintBarCode(IntPtr pBatchInfo,IntPtr pBarcodeinfoArray);用的时候先定义你的结构体,将数据传送进去如m_DataTransInfo IntPtr m_DataTransInfo1 = Marshal.AllocHGlobal(Marshal.SizeOf(m_DataTransInfo)); Marshal.StructureToPtr(m_DataTransInfo, m_DataTransInfo1, true);上面2个函数是将结构体转为IntPtr的形式,
之后你应该知道怎么做了吧!!希望有用啦
public struct BarcodeInfo
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
public string ShowContent;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
public string BarcodeContent; };
2、函数声明:[DllImport("LabelPrint.dll", CharSet = CharSet.Ansi]
public static extern int PrintBarCode(ref BarcodeInfo pBatchInfo,[In,Out]BarcodeInfo[] pBarcodeinfoArray,int size);