有熟悉c\c++的进来看看,看这个结构怎么对应到C#

格拉 2014-10-15 04:48:02
最近在弄mtp操作手机的东西,但是C#好像没有直接能操作的东西,有的就是c\c++的。像下面这个结构怎么对应到c#中,帮忙看看
/* 
* MtpDevice - generic MTP device
*
*/
struct _MtpDevice;

/**
* @brief Structure for providing access and support for MTP device information and control. For API documentation, please see ::_MtpDevice.
*/
typedef struct _MtpDevice MtpDevice;

struct _MtpDevice
{
/* ////////////////////////////////////////////////////////////////////////////////////////////
* Device opening/closing
*/

/**
* @brief Opens the specified MTP Device.
* @param This A pointer to ::MtpDevice.
* @param bstrDevicePortName An ::MTP_STRING representing the device name. This is transport-specific. Using the provided Windows USB transport, it is of the form "\\\\.\\wpdusbN" where N is an zero-based integer.
* @param MtpEventCallback A ::MtpEventCallback representing the address of object supporting event callback interface.
* This may be @a NULL if client doesn't want to receive events.
* @param dwReserved An ::MTP_UINT32 that is reserved for future transports. Always set to 0.
* @return An ::MTP_RESULT code that identifies the result of calling the function.
*
* This function must be called before any other function.
*
* Client must call Close() after it's finished working with the device.
*/
MTP_RESULT (*Open)(MtpDevice *This,
/*[in]*/ MTP_STRING bstrDevicePortName,
/*[in]*/ MtpEventCallback Callback,
/*[in, defaultvalue(0)]*/ MTP_UINT32 dwReserved);

/**
* @brief Closes the MTP Device.
* @param This A pointer to the ::MtpDevice.
* @return An ::MTP_RESULT code that identifies the result of calling the function.
*/
MTP_RESULT (*Close)(MtpDevice *This);

};
...全文
72 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
格拉 2014-10-15
  • 打赏
  • 举报
回复
引用 3 楼 gxingmin 的回复:
嗯,用类好点
多谢!
gxingmin 2014-10-15
  • 打赏
  • 举报
回复
嗯,用类好点
格拉 2014-10-15
  • 打赏
  • 举报
回复
引用 1 楼 gxingmin 的回复:
struct _MtpDevice
{
    /* ////////////////////////////////////////////////////////////////////////////////////////////
     *  Device opening/closing
     */
 
   /**
    * @brief Opens the specified MTP Device.
    * @param This A pointer to ::MtpDevice.
    * @param bstrDevicePortName An ::MTP_STRING representing the device name.  This is transport-specific.  Using the provided Windows USB transport, it is of the form "\\\\.\\wpdusbN" where N is an zero-based integer.
    * @param MtpEventCallback A ::MtpEventCallback representing the address of object supporting event callback interface. 
 *                             This may be @a NULL if client doesn't want to receive events.
    * @param dwReserved An ::MTP_UINT32 that is reserved for future transports. Always set to 0.
    * @return An ::MTP_RESULT code that identifies the result of calling the function.
    *
    * This function must be called before any other function.
    *
    * Client must call Close() after it's finished working with the device.
    */
    int Open(_MtpDevice This, 
                    /*[in]*/ string bstrDevicePortName, 
                    /*[in]*/ MtpEventCallback Callback,
                    /*[in, defaultvalue(0)]*/ int dwReserved)
{
}
 
   /**
    * @brief Closes the MTP Device.
    * @param This A pointer to the ::MtpDevice.
    * @return An ::MTP_RESULT code that identifies the result of calling the function.
    */
    int Close(_MtpDevice This)
   {
   }
 
};
这样的话是不是用类对应比较好?
gxingmin 2014-10-15
  • 打赏
  • 举报
回复
struct _MtpDevice
{
    /* ////////////////////////////////////////////////////////////////////////////////////////////
     *  Device opening/closing
     */
 
   /**
    * @brief Opens the specified MTP Device.
    * @param This A pointer to ::MtpDevice.
    * @param bstrDevicePortName An ::MTP_STRING representing the device name.  This is transport-specific.  Using the provided Windows USB transport, it is of the form "\\\\.\\wpdusbN" where N is an zero-based integer.
    * @param MtpEventCallback A ::MtpEventCallback representing the address of object supporting event callback interface. 
 *                             This may be @a NULL if client doesn't want to receive events.
    * @param dwReserved An ::MTP_UINT32 that is reserved for future transports. Always set to 0.
    * @return An ::MTP_RESULT code that identifies the result of calling the function.
    *
    * This function must be called before any other function.
    *
    * Client must call Close() after it's finished working with the device.
    */
    int Open(_MtpDevice This, 
                    /*[in]*/ string bstrDevicePortName, 
                    /*[in]*/ MtpEventCallback Callback,
                    /*[in, defaultvalue(0)]*/ int dwReserved)
{
}
 
   /**
    * @brief Closes the MTP Device.
    * @param This A pointer to the ::MtpDevice.
    * @return An ::MTP_RESULT code that identifies the result of calling the function.
    */
    int Close(_MtpDevice This)
   {
   }
 
};

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧