TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
gongdehui
NA
63
0
Error 1784 when invoke SetupDiGetDeviceInterfaceDetail() in C#
Nov 7 2004 9:44 AM
//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????
Reply
Answers (
4
)
Question about Marshal
Listbox help