momer
驱动牛犊
驱动牛犊
  • 注册日期2004-06-23
  • 最后登录2006-03-10
  • 粉丝0
  • 关注0
  • 积分147分
  • 威望18点
  • 贡献值0点
  • 好评度12点
  • 原创分0分
  • 专家分0分
阅读:1331回复:0

各位高手同志请帮忙!!!

楼主#
更多 发布于:2004-11-10 10:46
//c# code:
public class Win32 {......
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public struct SP_DEVICE_INTERFACE_DETAIL_DATA
{
public uint cbSize;
public char* DevicePath;
}
[DllImport("setupapi.dll", CharSet=CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupDiGetDeviceInterfaceDetail(
[In]IntPtr DeviceInfoSet,
[In] SP_DEVICE_INTERFACE_DATA *DeviceInterfaceData,
[Out]SP_DEVICE_INTERFACE_DETAIL_DATA *DeviceInterfaceDetailData,
[In]int DeviceInterfaceDetailDataSize,
[Out]int *RequiredSize,
[Out]SP_DEVINFO_DATA *DeviceInfoData
);
......
}

public class usbdevice {......
ptrDeviceInterfaceDetailData = (Win32.SP_DEVICE_INTERFACE_DETAIL_DATA*)Win32.GlobalAlloc(Win32.GPTR,nBytesRequired);

ptrDeviceInterfaceDetailData->cbSize = (uint)sizeof(Win32.SP_DEVICE_INTERFACE_DETAIL_DATA);

ptrDeviceInfoData->cbSize = Marshal.SizeOf( new Win32.SP_DEVINFO_DATA().GetType() );

bResult =Win32.SetupDiGetDeviceInterfaceDetail(hDevInfo,
ptrDeviceInterfaceData,
ptrDeviceInterfaceDetailData, //[out] pointer to a buffer to store the interface detail data
nBytesRequired, // the buffer size
null,
ptrDeviceInfoData);

lasterror = Win32.GetLastError();// Error number:1784. How to settle this problem????

[编辑 -  11/10/04 by  momer]
游客

返回顶部