Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than setupapi, prefix the name with the module name and a period.
SetupDiEnumDeviceInfo (setupapi)
.
Summary:
Returns a SP_DEVINFO_DATA structure that specifies a device information element in a device information set.
<DllImport("setupapi.dll", _
EntryPoint:="SetupDiEnumDeviceInfo", _
SetLastError:=True, _
CharSet:=CharSet.Unicode, _
ExactSpelling:=True, _
PreserveSig:=True, _
CallingConvention:=CallingConvention.Winapi)> _
Private Shared Function SetupDiEnumDeviceInfo( _
ByVal DeviceInfoSet As Integer, _
ByVal MemberIndex As Integer, _
ByRef DeviceInfoData As SP_DEVINFO_DATA) As Boolean
End Function
VB.Net Signature:
Private Declare Auto Function SetupDiEnumDeviceInfo Lib "setupapi.dll" ( _
ByVal DeviceInfoSet As Integer, _
ByVal MemberIndex As Integer, _
ByRef DeviceInfoData As SP_DEVINFO_DATA) As Boolean
The SetupDiEnumDeviceInfo function retrieves a context structure for a device information element of the specified device information set. Each call returns information about one device. The function can be called repeatedly to get information about several devices.
in Zero-based index to the list of interfaces in the device information set. You should first call this function with the MemberIndex parameter set to zero to obtain the first interface. Then, repeatedly increment MemberIndex and retrieve an interface until this function fails and GetLastError returns ERROR_NO_MORE_ITEMS (259).
out Pointer to an SP_DEVINFO_DATA structure that receives information about this element. You must set the cbSize member to sizeof(SP_DEVINFO_DATA) before calling this function.
Sample Code:
Please add some!
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
// Use the "enumerator form" of the SetupDiGetClassDevs API
// to generate a list of all USB devices
IntPtr h = SetupDiGetClassDevs(0, DevEnum, IntPtr.Zero, DIGCF_PRESENT | DIGCF_ALLCLASSES);
if (h.ToInt32() != INVALID_HANDLE_VALUE)
{
IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE);
string KeyName;
bool Success = true;
int i = 0;
while (Success)
{
// create a Device Interface Data structure
SP_DEVINFO_DATA da = new SP_DEVINFO_DATA();
da.cbSize = Marshal.SizeOf(da);
// start the enumeration
Success = SetupDiEnumDeviceInfo(h, i, ref da);
if (Success)
{
int RequiredSize = 0;
int RegType = REG_SZ;
KeyName = "";
if (SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref RegType, ptrBuf, BUFFER_SIZE, ref RequiredSize))
{
KeyName = Marshal.PtrToStringAuto(ptrBuf);
}
// is it a match?
if (KeyName == DriverKeyName)
{
if (SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DEVICEDESC, ref RegType, ptrBuf, BUFFER_SIZE, ref RequiredSize))
{
ans = Marshal.PtrToStringAuto(ptrBuf);
}
break;
}
}
i++;
}
Marshal.FreeHGlobal(ptrBuf);
SetupDiDestroyDeviceInfoList(h);
}
return ans;
}
defines a device instance that is a member of the device information set
4/21/2018 9:30:32 AM - 172.56.32.78
TODO - a short description
4/21/2018 9:24:00 AM - 172.56.32.78
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).