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
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
SerialDisplayAdvancedSettings (msports)
 
.
Summary
SerialDisplayAdvancedSettings displays the system-supplied advanced settings dialog box for a specified COM port device.

C# Signature:

[DllImport("msports.dll", SetLastError=true)]
static extern int SerialDisplayAdvancedSettings(IntPtr parentHwnd, IntPtr deviceInfoSet, ref SP_DEVINFO_DATA deviceInfoData);

VB Signature:

Declare Function SerialDisplayAdvancedSettings Lib "msports.dll" (TODO) As TODO

User-Defined Types:

SP_DEVINFO_DATA

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

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 == "...")
        {
            NativeMethods.SerialDisplayAdvancedSettings(IntPtr.Zero, deviceInfoSetHandle, ref deviceInfoData);
            return;
        }
    }
}
finally
{
    NativeMethods.SetupDiDestroyDeviceInfoList(deviceInfoSetHandle);
}

Documentation

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).

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