Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

SP_DEVICE_INTERFACE_DETAIL_DATA (Structures)
 
.

The SP_DEVICE_INTERFACE_DETAIL_DATA structure provides detailed information about a particular device interface.

C# Definition:

  [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
  struct NativeDeviceInterfaceDetailData
  {
    public int    size;
    public char   devicePath;
  }

Alternative definition:

  [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
  struct SP_DEVICE_INTERFACE_DETAIL_DATA
  {
    public int cbSize;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = BUFFER_SIZE)]
    public string DevicePath;
  }

Members:

size

Size of the structure, in bytes.

devicePath

NULL-terminated string that specifies the device path.

Notes:

The cbSize parameter should be the size of the DWORD plus the first character of the string

SP_DEVICE_INTERFACE_DETAIL_DATA didd = new SP_DEVICE_INTERFACE_DETAIL_DATA();
didd.cbSize = 4 + Marshal.SystemDefaultCharSize; // trust me :)

Example:

unsafe internal string GetDeviceInterfaceDetail(ref DeviceInterfaceData.NativeDeviceInterfaceData devIfaceData)
{
  NativeDeviceInterfaceDetailData* devIfaceDetailData = null;

  try
  {
   int devIfaceDetailDataSize = 0;

   for (;;)
   {
    int result = SetupDiGetDeviceInterfaceDetail(
     _devInfoList, ref devIfaceData, ref *devIfaceDetailData, devIfaceDetailDataSize, out devIfaceDetailDataSize, IntPtr.Zero);

    if (result == 0 && Marshal.GetLastWin32Error() != ErrorInsufficientBuffer)
     throw new Win32Exception();

    if (result != 0)
     break;

    Marshal.FreeHGlobal((IntPtr)devIfaceDetailData);
    devIfaceDetailData = (NativeDeviceInterfaceDetailData*)Marshal.AllocHGlobal(devIfaceDetailDataSize);

    devIfaceDetailData->size = Marshal.SizeOf(
     typeof(NativeDeviceInterfaceDetailData));
   }

   return Marshal.PtrToStringAuto(new IntPtr(&devIfaceDetailData->devicePath));

  }
  finally
  {
   Marshal.FreeHGlobal((IntPtr)devIfaceDetailData);
  }
}

Documentation

Please edit this page!

Do you have...

  • helpful tips?
  • corrections to the existing content?
  • alternate definitions?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions