阅读:1332回复:0
各位高手同志请帮忙!!!
//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] |
|