Chinaunix首页 | 论坛 | 博客
  • 博客访问: 588111
  • 博文数量: 141
  • 博客积分: 3425
  • 博客等级: 中校
  • 技术积分: 1609
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-23 15:55
文章分类

全部博文(141)

文章存档

2019年(5)

2011年(19)

2010年(36)

2009年(13)

2008年(50)

2007年(18)

分类:

2010-05-12 17:01:26

C#互操作声明:

class SiUSBXp
    {
        [DllImport("SiUSBXp.dll", CharSet = CharSet.Ansi)]
        public static extern int SI_GetNumDevices(ref IntPtr NumDevice);
        [DllImport("SiUSBXp.dll", CharSet = CharSet.Ansi)]
        public static extern int SI_GetProductString(int DeviceNum,
                                                                                       StringBuilder DeviceString,
                                                                                       int Options);
        [DllImport("SiUSBXp.dll", CharSet = CharSet.Ansi)]
        public static extern int SI_Open(int DeviceNum, ref IntPtr Handle);
        [DllImport("SiUSBXp.dll", CharSet = CharSet.Ansi)]
        public static extern int SI_Close(IntPtr Handle);
        [DllImport("SiUSBXp.dll", CharSet = CharSet.Ansi)]
        public static extern int SI_Read(IntPtr Handle,
                                                                 StringBuilder buffer,
                                                                 int NumBytesToRead,
                                                                 ref IntPtr NumBytesReturned,
                                                                 int overlaped);
        [DllImport("SiUSBXp.dll", CharSet = CharSet.Ansi)]
        public static extern int SI_SetTimeouts(int ReadTimeout, int WriteTimeout);
        [DllImport("SiUSBXp.dll", CharSet = CharSet.Ansi)]
        public static extern int SI_FlushBuffers(IntPtr Handle, byte valR, byte valT);
    }

DLL中原型:


SI_STATUS SI_GetNumDevices (LPDWORD NumDevices);

SI_STATUS SI_GetProductString (DWORD DeviceNum,
                               LPVOID DeviceString,
                               DWORD Options);

SI_STATUS SI_Open (DWORD DeviceNum, HANDLE *Handle);

SI_STATUS SI_Close (HANDLE Handle);

SI_STATUS SI_Read (HANDLE Handle,
                   LPVOID Buffer,
                   DWORD NumBytesToRead,
                   DWORD*NumBytesReturned,
                   OVERLAPPED* o = NULL);

SI_STATUS SI_FlushBuffers (HANDLE Handle,
                           BYTE FlushTransmit,
                           BYTE FlushReceive);

SI_STATUS SI_SetTimeouts (DWORD ReadTimeout, DWORD WriteTimeout);


阅读(2544) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~