[DllImport("setupapi.dll", SetLastError=true)]
public static extern int CM_Get_DevNode_Registry_Property(
uint dnDevInst,
uint ulProperty,
out Microsoft.Win32.RegistryValueKind pulRegDataType,
IntPtr Buffer,
ref uint pulLength,
uint ulFlags);
Declare Function CM_Get_DevNode_Registry_Property Lib "setupapi.dll" (TODO) As TODO
None.
Do you know one? Please contribute it!
In most cases you can use SetupDiGetDeviceRegistryProperty.
Also Microsoft.Win32.RegistryValueKind only contains enumerations for the basic kinds.
Please add some!
// The following code shows how to grab the parent device's driver name. The devinfo_data.DevInst is
// from SetupDiEnumDeviceInterfaces and SetupDiGetDeviceInterfaceDetail so please see those examples
string driver_name;
uint parent;
if (CR_SUCCESS == CM_Get_Parent(out parent, devinfo_data.DevInst, 0))
{
Microsoft.Win32.RegistryValueKind kind;
uint length = 0;
CM_Get_DevNode_Registry_Property(devinst, CM_DRP_DRIVER, out kind, IntPtr.Zero, ref length, 0);
if (length > 0)
{
IntPtr buffer = Marshal.AllocHGlobal((int)length);
if (CR_SUCCESS == CM_Get_DevNode_Registry_Property(devinst, CM_DRP_DRIVER, out kind, buffer, ref length, 0))
driver_name = Marshal.PtrToStringAnsi(buffer);
Marshal.FreeHGlobal(buffer);
}
}