大家好:
  我是一个刚刚学习c#的新手。在开发中遇到了以下问题:    c#调用vc++动态链接库的函数,dll的接口函数为:
    int WINAPI rf_request(unsigned short icdev, 
                            unsigned char  model, 
                            unsigned short *pTagType);    如何编写访问这个函数的代码呢?我查了一些资料,有说用string,ref,out,Intptr,unsafe等等,不过我都没有试成功。希望哪位好心人能过给出完整的代码。非常感谢!

解决方案 »

  1.   

    unsigned short: uint16
    unsigned char: byteunsigned short*:
    // It's an array type
    [MarshalAs(UnmanagedType.LPArray)]uint16[]
    or with "In" or "Out" attribute
    [In, MarshalAs(UnmanagedType.LPArray)]uint16[]// It's a pointer type
    ref uint16
      

  2.   

    谢谢Knight94.
    你给的代码,关于数据结构的那部分,我是那样用的,可是其它的几句,我就看不懂了,能否解释的详细一些。谢谢