我想操作USB设备,但 SP_DEVICE_INTERFACE_DETAIL_DATA不知道如何定义,它的定义跟函数SetupDiGetDeviceInterfaceDetail有关,我定义如下:
[StructLayout( LayoutKind.Sequential )]
public class SP_DEVICE_INTERFACE_DETAIL_DATA
{
public uint cbSize;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 263 )]
public string DevicePath;
};
函数定义如下:
[DllImport("setupapi.dll", SetLastError=true)]
public static extern bool SetupDiGetDeviceInterfaceDetail(
IntPtr DeviceInfoSet,
SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
SP_DEVICE_INTERFACE_DETAIL_DATA DeviceInterfaceDetailData,
uint DeviceInterfaceDetailDataSize,
ref uint RequiredSize,
SP_DEVINFO_DATA DeviceInfoData);
函数是调用成功了,可是DeviceInterfaceDetailData.DevicePath 为 null 不知道为什么,请高手指点。
[StructLayout( LayoutKind.Sequential )]
public class SP_DEVICE_INTERFACE_DETAIL_DATA
{
public uint cbSize;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 263 )]
public string DevicePath;
};
函数定义如下:
[DllImport("setupapi.dll", SetLastError=true)]
public static extern bool SetupDiGetDeviceInterfaceDetail(
IntPtr DeviceInfoSet,
SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
SP_DEVICE_INTERFACE_DETAIL_DATA DeviceInterfaceDetailData,
uint DeviceInterfaceDetailDataSize,
ref uint RequiredSize,
SP_DEVINFO_DATA DeviceInfoData);
函数是调用成功了,可是DeviceInterfaceDetailData.DevicePath 为 null 不知道为什么,请高手指点。
解决方案 »
- 如何用最简单的方法转换这个日期格式???
- 请问老手 vs2008给相关控件添加数据绑定项 出现“未指定的错误”提示怎么解决
- 怎样过滤List或者ComboBox中相同的选项?在线等!
- 写个冰封王座的平台,指个方向吧
- C#查询多表条件查询
- 在线求个读取txt文本的问题!谢谢
- 用命令如何调那个outlook,好像点一下去那它就会弹出那个发邮件的东西出来,我是新手,帮帮小弟好吗
- 不用每个文本框都要设全选中问题
- 求救高手,信息采集技术,那位高手做过信息采集的软件请指点一二,
- 谁有datalist的示例代码
- C# winform datagrid 获得值后 单击单元格时 它的底色怎么设置阿
- Backspace代码实现
An SP_DEVICE_INTERFACE_DETAIL_DATA structure contains the path for a device interface.typedef struct _SP_DEVICE_INTERFACE_DETAIL_DATA {
DWORD cbSize;
TCHAR DevicePath[ANYSIZE_ARRAY];
} SP_DEVICE_INTERFACE_DETAIL_DATA, *PSP_DEVICE_INTERFACE_DETAIL_DATA;
Members
cbSize
The size, in bytes, of the fixed portion of the SP_DEVICE_INTERFACE_DETAIL_DATA structure.
DevicePath
A NULL-terminated string that contains the device interface path. This path can be passed to Win32 functions such as CreateFile. Headers
Defined in setupapi.h. Include setupapi.h.
[DllImport("setupapi.dll", SetLastError=true)]
public static extern bool SetupDiGetDeviceInterfaceDetail(
IntPtr DeviceInfoSet,
SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
IntPtr DeviceInterfaceDetailData,
//SP_DEVICE_INTERFACE_DETAIL_DATA DeviceInterfaceDetailData,
uint DeviceInterfaceDetailDataSize,
ref uint RequiredSize,
SP_DEVINFO_DATA DeviceInfoData);
这样是可以,谢谢各位关注