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 msports, prefix the name with the module name and a period.
var deviceClassGuid = Guid.Parse("{4d36e978-e325-11ce-bfc1-08002be10318}"); // Ports class GUID
const int DIGCF_PRESENT = 0x2;
IntPtr deviceInfoSetHandle = NativeMethods.SetupDiGetClassDevs(ref deviceClassGuid, null, IntPtr.Zero, DIGCF_PRESENT);
try
{
// search frendlyName and open advanced settings
var deviceInfoData = new SP_DEVINFO_DATA();
deviceInfoData.CbSize = (uint)Marshal.SizeOf(deviceInfoData);
uint index = 0;
while (NativeMethods.SetupDiEnumDeviceInfo(deviceInfoSetHandle, index++, ref deviceInfoData))
{
var buffer = new byte[300];
const uint SPDRP_FRIENDLYNAME = 0xC;
NativeMethods.SetupDiGetDeviceRegistryProperty(deviceInfoSetHandle, ref deviceInfoData, SPDRP_FRIENDLYNAME, out var _, buffer, (uint)buffer.Length, out var _);
var friendlyName = Encoding.Unicode.GetString(buffer).TrimEnd('\0');
if (friendlyName == "...")
var ptrBuffer = new IntPtr();
const int bufferSize = 300;
ptrBuffer = Marshal.AllocHGlobal(bufferSize);
try
{
NativeMethods.SerialDisplayAdvancedSettings(IntPtr.Zero, deviceInfoSetHandle, ref deviceInfoData);
return;
const uint SPDRP_FRIENDLYNAME = 0xC;
NativeMethods.SetupDiGetDeviceRegistryProperty(deviceInfoSetHandle, ref deviceInfoData, SPDRP_FRIENDLYNAME, out var _, ptrBuffer, bufferSize, out var _);
SerialDisplayAdvancedSettings displays the system-supplied advanced settings dialog box for a specified COM port device.
2/23/2020 9:49:46 PM - -14.9.137.224
defines a device instance that is a member of the device information set
4/21/2018 9:30:32 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).