typedef struct _COMMPORTCONFIG {
DWORD BaudRate; // baud rate
DWORD ByteSize; // number of bits/byte, 4-8
DWORD Parity; // 0-4=no,odd,even,,space
DWORD StopBits; // 0,1,2 = 1, 1.5, 2
DWORD fOutxCtsFlow; // CTS Flow Control
} COMMPORTCONFIG;
C/C++:
BOOL MetrocomInitCommunication(int i_port, COMMPORTCONFIG * p_config);
现在我如何转成C#可以引用的,还有要怎么调用?
解决方案 »
- try{x.get(0)}catch{return null}和if x<1 return null 哪个快
- C# 里面为什么要用一个 interface?
- 一个有意思的问题,XML 反序列化回调如何实现?
- (效率)(效率)如何判断泛型list中是否有相同的元素?怎么去除相同的元素只保留一个
- WPF,求一本好书?
- 类库能否读取配置文件?我用app.config没用,读不到,但也不出错。
- 一个小问题 是小问题
- 请问各位大侠 VS2012 c#开发的wpf工程如何打包安装?
- datagrid里面怎么让选中的整行颜色改变?
- datagrid双击如何实现??谢谢了!
- 用c#写出链表的创建、增加节点、删除节点、查找 ?
- C# 自动锁定功能如何实现
DLL 传递结构 (见代码)
BOOL PtInRect(const RECT *lprc, POINT pt); using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)]
public struct Point {
public int x;
public int y;
}
[StructLayout(LayoutKind.Explicit)]
public struct Rect
{
[FieldOffset(0)] public int left;
[FieldOffset(4)] public int top;
[FieldOffset(8)] public int right;
[FieldOffset(12)] public int bottom;
}
Class XXXX {
[DllImport("User32.dll")]
public static extern bool PtInRect(ref Rect r, Point p);
}
{
int BaudRate; // baud rate
int ByteSize; // number of bits/byte, 4-8
int Parity; // 0-4=no,odd,even,,space
int StopBits; // 0,1,2 = 1, 1.5, 2
int fOutxCtsFlow; // CTS Flow Control
} [DllImport("DLL文件名")]
public static extern bool MetrocomInitCommunication(int i_port, ref COMMPORTCONFIG p_config);
[DllImport("你DLL名称")]
public static extern bool MetrocomInitCommunication(int i_port, ref COMMPORTCONFIG p_config);[StructLayout(LayoutKind.Sequential)]
public struct _COMMPORTCONFIG {
int BaudRate; // baud rate
int ByteSize; // number of bits/byte, 4-8
int Parity; // 0-4=no,odd,even,,space
int StopBits; // 0,1,2 = 1, 1.5, 2
int fOutxCtsFlow; // CTS Flow Control
}int i_port;
COMMPORTCONFIG p_config=new COMMPORTCONFIG ();
MetrocomInitCommunication(i_port, ref p_config);