Windows list com ports

Getting a List of Serial Ports in the System and Finding the COM Port of an Application

Working with COM ports is a common task for professionals involved in debugging and maintaining industrial equipment, system administrators, and DIY enthusiasts. These ports are used for communication with various devices, such as microcontrollers, sensors, and other systems that operate through a serial interface. Sometimes, during operation, it is necessary to determine which COM ports are available on the computer and to view the data transmitted through them.

Knowing the COM ports on a computer is important when working with a new or unknown device, as the COM port number (e.g., COM10) is essential for communication with that device.

How to view all COM ports on Windows

The task may not be as simple and obvious. The easiest way is to open Devices Manager, go to the Ports group, and view the list there. However, this does not always work:

  • Your device may be in an unexpected place in Devices Manager (e.g., Modems).
  • The port number may not be displayed next to the device name, requiring you to dig into the device settings (e.g., multi-port adapters or virtual devices).
  • The device may create multiple ports for one physical device (e.g., Bluetooth devices).

To solve this problem, you can use Advanced Serial Port Monitor. The program can identify ports in several ways to obtain the most complete list with the port number and its description:

  1. Download Serial Port Monitor (the first link) and install it on your computer. During installation, you can leave all options at their default settings.
  2. Run ASPM, and the program will determine all ports upon startup (see image).

List of COM ports with descriptions

How to find the COM port used by an application

On Windows, each COM port can be used by only one program, since it is opened in the exclusive mode. If the port number is unknown, it can be found by simple trial and error, sequentially trying to select and open the port using a program like Advanced Serial Port Monitor. When opening the port, you should use the «Manual» mode (Main menu → Mode) and relatively standard communication parameters 9600 8N1.

  1. Run Serial Port Monitor.
  2. Select the desired port from the list.
  3. Click the «Open» button.
  4. If the text on the button changes to «Close» and no error message is displayed, the port has been successfully opened and is not in use by another program.
  5. If the port could not be opened, it may be that another program is using it; ASPM will show the name of the process that is using that port. This is often accompanied by an error message: Port busy, Access denied.
  6. If it is possible, stop the program using the port and try to open it again to confirm that it was indeed occupying the port.

How to detect the communication parameters of an application

The Advanced Serial Port Monitor program allows you not only to view data transmitted through the COM port, but also to determine communication parameters. This can be useful if you need to find out the settings of an application interacting with an external device via a serial interface. Communication parameters include: baud rate, number of data bits or stop bits, parity check, and others. To determine communication parameters, you need to do the following:

  1. Close the application that interacts with the external device.
  2. Run Serial Port Monitor.
  3. Go to program settings «Options → Program settings → Data view → System events», and ensure that checkboxes are marked for all system events in the list. Click «OK» to save the changed settings.
  4. Select the desired port from the list.
  5. Select «Mode → Spy».
  6. Click the «Open» button.
  7. Run your application and initiate data exchange within it for a few seconds.
  8. The main window of the program will display data exchange and system events highlighted in red. It is more convenient to use the «ASCII» data window for viewing events.
  9. Close the port to stop data flow.
  10. Scroll to the top of the data window.
  11. Look for lines with «Baud rate» and «Data bits,» which contain the communication parameters used by another application when opening the port.

System events in the main program window

Download a free trial version
Helps diagnose problems

See also

RS232 Analyzer from Advanced Serial Port Monitor
RS232 Monitor is a unique monitoring tool for communications via RS-232
Capture and analyze COM port traffic with our Windows RS232 serial port sniffer
Spying on a serial port or RS232 port using our Serial Port Monitor software
RS232 terminal
UART monitoring using our Serial Port Monitor
COM port scanner
5 common errors with COM port operations in Windows
How to find application COM port and list all COM ports in Windows

Check COM Ports in the Device Manager

The Device Manager is the easiest way to see the list of your available ports. Generally, if you want to inspect your PC’s components, it’s the first place to look. There are multiple ways to open the Device Manager to see Windows 10 COM ports:

Press Win+X, and select it from the newly opened menu.

The system tool menu available from Win+X

Press Win+R to open the Run prompt, and type in devmgmt.msc.

The Run window, ready to launch the Device Manager

Simply type “Device” into the search bar, and find it in the search results.

Windows Search automatically completing

If you have problems with COM ports not showing in Device Manager, this could be caused by a different version of Windows that hides them by default, a technical issue with your motherboard, or a lack of drivers for a USB-to-serial adapter.

How to Find COM Ports on Windows 10

  1. Open the Device Manager.

An overview of the Device Manager

  1. Optionally, enable “View” → “Show Hidden Devices”.
  1. Locate “Ports (COM and LPT)”.

The Ports category is highlighted and expanded, revealing COM1 and COM2

You can now right-click any individual port to view their Windows 10 COM port settings, and possibly disable them or update their drivers.

List COM Ports — Windows 10 Command Line Solution

If you’d want to know how to view COM ports in Windows 10 through the Command Prompt, it’s easy, but first you need to launch CMD. This is done by entering “cmd” in the Run prompt, which is opened with Win+R.

Once the terminal is opened, type mode and confirm by pressing Enter. You will get data on the available ports and their settings.

The output of

Some details on how to check COM port in Windows 11 are different, since the addition of the Windows Terminal.

What Port Am I Using?

COM ports are simple — unlike USB, the devices won’t identify themselves. Thus, the only way to see if anything is connected to a Windows 10 COM port is to receive a message from the connected device. This can be done with PowerShell. Before trying this approach, you’ll need to find the correct settings to be used when communicating with the device, including the baud rate, parity bits, etc.

How to Find what COM Port a Device is On

  1. Open PowerShell by pressing Win+X and selecting “Windows PowerShell (Admin)”.

The PowerShell administrator option highlighted in the Win+X menu

  1. Add the port as an object:
    $port = New-Object System.IO.Ports.SerialPort [port name],[baud rate],[parity],[data bits],[stop bits]
  2. Open the port with the $port.Open() command.

The $port object is created and opened

  1. You can now read a single line from the port or send a message to it by running $port.WriteLine() or $port.ReadLine().

A test message is sent, and $port is waiting to read a line

ReadLine will keep running until it receives one line of data. If you want to read from the port continuously, this is best done with a serial terminal application.

When it comes to navigating the world of technology, understanding how to find COM ports on Windows 10 can be a valuable skill. These communication ports play a crucial role in connecting peripheral devices to your computer, allowing for data transfer and device control. But how exactly can you locate these ports on your Windows 10 system?

Windows 10 provides an intuitive method for finding COM ports, ensuring that users can easily access and utilize these essential connections. By accessing the Device Manager, you can view a comprehensive list of all the COM ports available on your system. This not only allows you to identify the COM ports, but also provides information about the devices connected to them. Having this knowledge empowers you to troubleshoot connection issues and optimize the performance of your peripheral devices.

If you’re looking to find COM ports on Windows 10, follow these steps:

  1. Open the Device Manager by pressing the Windows key + X and selecting «Device Manager» from the menu.
  2. In the Device Manager window, click on the «Ports (COM & LPT)» category to expand it.
  3. You’ll find a list of COM ports on your computer. Note that each port is labeled with a number (e.g., COM1, COM2).
  4. To get more information about a specific port, right-click on it and select «Properties.»
  5. In the Properties window, you can view details such as the port’s status, driver information, and settings.

How To Find Com Ports On Windows 10

Introduction to Finding COM Ports on Windows 10

Communication ports, commonly known as COM ports, play a crucial role in connecting external devices to your Windows 10 computer. These ports facilitate the transfer of data between your PC and peripherals like printers, scanners, and serial devices. For experts working with hardware and troubleshooting, it’s essential to know how to find COM ports on Windows 10. In this article, we will explore different methods and tools to uncover and manage these ports effectively.

Method 1: Device Manager

The Device Manager utility in Windows 10 offers a convenient way to access and manage COM ports on your system. Here’s how:

  • Right-click on the Start button and select «Device Manager» from the menu.
  • In the Device Manager window, locate and click on the «Ports (COM & LPT)» category.
  • Expand the category to view all the available COM ports on your system.
  • Each COM port is listed with its corresponding number.

Using Device Manager to Troubleshoot COM Port Issues

If you are experiencing problems with a specific COM port or device, Device Manager can come in handy for troubleshooting:

  • Right-click on the problematic COM port and select «Properties» from the context menu.
  • In the Properties window, navigate to the «Port Settings» tab and click on the «Advanced» button.
  • Here, you can adjust various settings like the baud rate, flow control, and latency.

Method 2: PowerShell Command

PowerShell is a powerful command-line tool that allows you to perform advanced system operations on Windows 10. You can also use the following PowerShell command to find the COM ports on your system:

Get-WmiObject Win32_SerialPort

This command fetches information about the serial ports on your computer, including the COM port number, name, and description. To use this method:

  • Open PowerShell by searching for it in the Start menu.
  • Type the command Get-WmiObject Win32_SerialPort and press Enter.
  • The PowerShell window will display a list of all the COM ports with their details.

Filtering the COM Port List in PowerShell

If you want to filter the COM port list based on specific properties, you can modify the PowerShell command with additional parameters. For example:

Get-WmiObject Win32_SerialPort | Where-Object {$_.Name -like "*COM3*"}

This command will filter the list and display only the COM ports that contain «COM3» in their name. You can replace «COM3» with any other COM port number to suit your requirements.

Method 3: SerialPort Utility

If you prefer a graphical user interface (GUI) instead of command-line tools, you can use a third-party software called SerialPort Utility to find and manage COM ports on Windows 10. Here’s how:

  • Download and install the SerialPort Utility software from a reputable source.
  • Launch the application.
  • The interface will display a list of available COM ports along with their status and details.

Managing COM Ports with SerialPort Utility

In addition to providing basic information about COM ports, SerialPort Utility offers various features to manage and test these ports:

  • Toggle the status of a COM port to enable or disable it.
  • Monitor the incoming and outgoing data on a COM port.
  • Perform loopback tests to check the functionality of a COM port.

Exploring Additional Dimensions of Finding COM Ports on Windows 10

Aside from the methods mentioned above, there are other interesting aspects to consider when dealing with COM ports on Windows 10. Let’s explore a few more:

Using Device Management Software

Device management software can provide a comprehensive view of all the connected devices and their corresponding COM ports on your Windows 10 system. These software tools offer advanced features for monitoring, configuring, and troubleshooting devices efficiently. Some popular options include:

Software Features
Serial Port Monitor Real-time monitoring, diagnostics, and analysis of COM ports.
Advanced Serial Port Monitor Monitoring, analyzing, and logging data from COM ports.
Serial Port Tool Data transmission, logging, and debugging for COM ports.

Benefits of Device Management Software

Using dedicated device management software can provide several advantages over manual methods:

  • Real-time monitoring of COM ports and connected devices.
  • Enhanced diagnostics and troubleshooting capabilities.
  • Advanced data analysis and logging features.
  • Automation options to streamline device management tasks.

Virtual COM Ports

Virtual COM ports, also known as software COM ports, are a useful concept that allows software applications to communicate with virtual devices as if they were physical COM ports. These virtual ports can be created using specialized software tools like:

Software Features
Virtual Serial Port Driver Creation and management of virtual COM ports.
Virtual Serial Port Emulator Creation and emulation of virtual COM ports.
Eltima Virtual Serial Port Creation and testing of virtual COM ports.

Applications of Virtual COM Ports

Virtual COM ports offer various applications in scenarios where physical connections are not feasible or practical:

  • Testing and development of software applications that require COM port communication.
  • Simulating and emulating hardware devices for virtual testing.
  • Creating virtual connections between remote devices over networks.

These software tools enable seamless communication between software applications and virtual devices, eliminating the need for physical hardware.

Hardware Serial Port Expansion Cards

In certain cases, the number of COM ports available on your Windows 10 computer may be inadequate for your specific requirements. In such situations, you can consider using hardware serial port expansion cards. These cards can be added to your PC to provide additional physical COM ports for connecting peripherals and devices.

Serial port expansion cards are available in various configurations, offering multiple COM ports on a single card. They can be connected to an available PCI or PCIe slot on your motherboard. Once installed, you can access and manage these additional COM ports using the methods mentioned earlier.

Choosing a Serial Port Expansion Card

When selecting a serial port expansion card, consider the following factors:

  • Compatibility with your computer’s motherboard and operating system.
  • The number of additional COM ports required.
  • Support for advanced features like flow control and high-speed data transmission.
  • Reliability and reputation of the manufacturer.

Conclusion

Understanding how to find COM ports on Windows 10 is essential for hardware experts and troubleshooters. Whether you choose to utilize the built-in Device Manager, use PowerShell commands, or leverage third-party tools like SerialPort Utility, there are various methods at your disposal. Additionally, exploring concepts like device management software, virtual COM ports, and serial port expansion cards offers a deeper understanding of the subject and expands your capabilities. By mastering the art of finding and managing COM ports, you can effectively connect and control external devices, ensuring smooth operation and optimal performance.

How To Find Com Ports On Windows 10

Finding Com Ports on Windows 10

When working with devices connected to your computer through a serial connection, you may need to find the COM ports they are using on your Windows 10 system. Here are two methods to help you locate the COM ports:

Using Device Manager

  • Press the Windows key + X on your keyboard to open the Power User menu.
  • From the menu, select Device Manager. The Device Manager window will open.
  • In the Device Manager, expand the category labeled Ports (COM & LPT) to view the list of COM ports on your computer.

Using PowerShell

  • Press the Windows key + X on your keyboard to open the Power User menu.
  • From the menu, select Windows PowerShell (Admin). The PowerShell window will open.
  • Type the following command: Get-WmiObject -query «SELECT * FROM Win32_PnPEntity WHERE Description LIKE ‘%(COM%'» and press Enter.
  • The PowerShell window will display a list of all the COM ports on your computer.

By following these methods, you can easily locate the COM ports on your Windows 10 system, allowing you to manage and troubleshoot devices connected through serial connections.

Key Takeaways: How to Find Com Ports on Windows 10

  • Com ports on Windows 10 can be found in the Device Manager.
  • To access the Device Manager, right-click the Start button and select «Device Manager.»
  • In the Device Manager, expand the «Ports (COM & LPT)» category.
  • The Com ports will be listed as «COM» followed by a number.
  • To check the properties of a Com port, right-click on it and select «Properties.»

Frequently Asked Questions

Here are some commonly asked questions about finding COM ports on Windows 10.

1. How do I check for available COM ports on Windows 10?

To check for available COM ports on Windows 10, follow these steps:

1. Open the Device Manager by pressing the Windows + X keys and selecting «Device Manager» from the menu.

2. In the Device Manager window, expand the «Ports (COM & LPT)» section.

3. The available COM ports on your computer will be listed under the «Ports (COM & LPT)» section.

4. Note down the COM port numbers for future reference.

By following these steps, you can easily check for available COM ports on Windows 10.

2. How can I find the COM port number of a specific device on Windows 10?

To find the COM port number of a specific device on Windows 10, you can use the Device Manager. Here’s how:

1. Connect the device for which you want to find the COM port number to your computer.

2. Open the Device Manager by pressing the Windows + X keys and selecting «Device Manager» from the menu.

3. In the Device Manager window, locate the device you want to find the COM port number for under the relevant category (e.g., «Ports (COM & LPT)»).

4. Right-click on the device and select «Properties» from the context menu.

5. In the device’s Properties window, go to the «Port Settings» tab.

6. The COM port number for the device will be displayed under the «Port» section.

By following these steps, you can easily find the COM port number of a specific device on Windows 10.

3. What should I do if I can’t find any COM ports on Windows 10?

If you can’t find any COM ports on Windows 10, try the following solutions:

1. Check if the device is properly connected to your computer. Ensure that the device is securely plugged into the appropriate port.

2. Restart your computer and check again. Sometimes, a simple restart can resolve connectivity issues and refresh the COM port list.

3. Update the device drivers. Outdated or incompatible drivers can cause issues with COM ports. Visit the manufacturer’s website and download the latest drivers for your device.

4. Check if the device is being recognized by your computer. Open the Device Manager and look for any unknown devices or devices with exclamation marks. If you find any, try uninstalling and reinstalling the drivers for those devices.

If none of these solutions work, it’s recommended to consult with a technical expert or contact the device manufacturer for further assistance.

4. Can I create virtual COM ports on Windows 10?

Yes, you can create virtual COM ports on Windows 10 using specialized software. Virtual COM ports allow your computer to communicate with virtual devices or software that require a COM port connection.

There are several software solutions available that enable you to create virtual COM ports. One popular option is the «Virtual Serial Port Driver» software, which allows you to create pairs of virtual COM ports that are linked together.

Before you create virtual COM ports, make sure you understand the purpose and requirements of the software or device you intend to connect to. Consult the software or device manufacturer’s documentation for specific instructions on creating and using virtual COM ports.

5. Are COM ports still used in modern computing?

Yes, COM ports are still used in modern computing, albeit less frequently than before. While technologies

So there you have it! Finding COM ports on Windows 10 is a simple process that can be done in just a few steps. By following the instructions in this article, you can easily locate and identify the COM ports on your Windows 10 computer.

Remember, COM ports are essential for connecting serial devices to your computer, so it’s important to know how to find them. Whether you need to troubleshoot a connection issue or simply want to check which COM ports are in use, the steps outlined in this article will help you accomplish that. Now you can easily navigate the world of COM ports on Windows 10 with confidence!

При программировании COM портов полезно иметь возможность получать список доступных портов на компьютере. Эта задача встречается настолько часто, что я решил затронуть ее в своем блоге.

Существует несколько различных способов решения этой задачи. Их все можно условно разделить на «некрасивые» и «красивые».

«Некрасивые» решения

Первый вариант заключается в том, чтобы зашить в программу самые распространенные номера портов (обычно COM1, COM2, COM3 и некоторые другие). Недостатком этого подхода является то, что вы не всегда можете охватить все доступные порты. Например, я видел системы, на которых встречается порты COM22, COM23, COM24 (порты были виртуальными, но суть вопроса это не меняет). Не будете же вы зашивать столько номеров. А если завтра встретится COM100?

Второй вариант заключается в проверке большого количества портов на их доступность. Мы просматриваем порты COM1, COM2, ….., COM100 и пытаемся открыть каждый из них. Если это удалось, значит, порт есть. У этого подхода несколько недостатков.

Во-первых, такой перебор занимает время, а регулярные вызовы функции CreateFile напрасно расходуют системные ресурсы.

Во-вторых, у данного метода возможны ложные срабатывания. Предположим, пользователь запустил программу, которая заняла порт COM3. После этого он запустил вашу программу. Разумеется, при попытке открыть порт COM3 возникнет ошибка, так как он занят другой программой. В результате чего программа решит, что такого порта нет. А он есть.

В-третьих, он не решает проблему охвата всего многообразия возможных портов.

«Красивое» решение

Красивое решение основывается на том факте, что информация о доступных COM портах (в том числе виртуальных) в системах Windows хранится в реестре. Точнее в ветке HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM\. Там COM порты хранятся в виде строк: «COM1», «COM2», «COM3» и т.д. Отсюда сразу возникает решение – нужно перебрать все строковые параметры в данном разделе реестра.

Ниже приводится полный исходный код примера, демонстрирующего данный метод.

#include <windows.h>
#include <tchar.h>

void ShowCOMPorts()
{
  int r = 0;
  HKEY hkey = NULL;
  //Открываем раздел реестра, в котором хранится иинформация о COM портах
  r = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM\\"), 0, KEY_READ, &hkey);
  if (r != ERROR_SUCCESS) 
    return;
  
  unsigned long CountValues = 0, MaxValueNameLen = 0, MaxValueLen = 0;
  //Получаем информацию об открытом разделе реестра
  RegQueryInfoKey(hkey, NULL, NULL, NULL, NULL, NULL, NULL, &CountValues, &MaxValueNameLen, &MaxValueLen, NULL, NULL);
  ++MaxValueNameLen;
  //Выделяем память
  TCHAR *bufferName = NULL, *bufferData = NULL;
  bufferName = (TCHAR*)malloc(MaxValueNameLen * sizeof(TCHAR));
  if (!bufferName)
  {
    RegCloseKey(hkey);
    return;
  }
  bufferData = (TCHAR*)malloc((MaxValueLen + 1)*sizeof(TCHAR));
  if (!bufferData) 
  { 
    free(bufferName); 
    RegCloseKey(hkey);
    return;
  }
  
  unsigned long NameLen, type, DataLen;
  //Цикл перебора параметров раздела реестра
  for (unsigned int i = 0; i < CountValues; i++)
  {
    NameLen = MaxValueNameLen;
    DataLen = MaxValueLen;
    r = RegEnumValue(hkey, i, bufferName, &NameLen, NULL, &type, (LPBYTE)bufferData, &DataLen);
    if ((r != ERROR_SUCCESS) || (type != REG_SZ))
      continue;		
    
    _tprintf(TEXT("%s\n"), bufferData);
  }
  //Освобождаем память
  free(bufferName);
  free(bufferData);
  //Закрываем раздел реестра
  RegCloseKey(hkey);
}

int main()
{
  ShowCOMPorts();
  return 0;
}

В заключение лишь отмечу, что я использую этот подход во многих своих проектах, и он еще ни разу не подводил меня.

Example

Getting all serial ports information from Windows is often necessary, you may want to give the user a choice of ports to open, or check if your device is connected.

In addition, some ports just cannot be opened using a «COMx» string and need to be opened using a device name. Some older versions of Windows cannot open ports named ‘COMxx’ when the port number is 10 or higher. So, using the device number is a sensible way to identify your com port with Windows.

Serial port information is held in the registry under the key HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM

This example in C shows how to list all the serial ports and how one can get to the device name to use for the call to CreateFile.

The method is quite simple:

  • Open the registry at HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM
  • Enumerate all keys we find there. The device name is the key name, and the ‘display name’ is the key value.

As is often the case with Windows programming, most of the effort is spent on error checking. It may seem a bit silly, but there’s no safe way to avoid it.

#define WIN32_LEAN_AND_MEAN  // excludes stuff frokm windows.h that we won't need here.
#include <Windows.h>
#include <string.h>
#include <tchar.h>
#include <malloc.h>

void ShowErrorFromLStatus(LSTATUS lResult)
{
    LPTSTR psz;
    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
        NULL,
        lResult,
        0,
        (LPTSTR)&psz,
        1024,
        NULL);

    _tprintf(_T("Windows reports error: (0x%08X): %s\n"), lResult, (psz) ? psz : _T("(null)"));
    if (psz)
    {
        LocalFree(psz);
    }
}

int main()
{
    DWORD nValues, nMaxValueNameLen, nMaxValueLen;
    HKEY hKey = NULL;
    LPTSTR szDeviceName = NULL;
    LPTSTR szFriendlyName = NULL;
    DWORD dwType = 0;
    DWORD nValueNameLen = 0;
    DWORD nValueLen = 0;
    DWORD dwIndex = 0;

    LSTATUS lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"HARDWARE\\DEVICEMAP\\SERIALCOMM", 0, KEY_READ, &hKey);
    if (ERROR_SUCCESS != lResult)
    {
        printf("Failed to open key \'HARDWARE\\DEVICEMAP\\SERIALCOMM\' \n");
        ShowErrorFromLStatus(lResult);
        return 1;
    }

    lResult = RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL,
        &nValues, &nMaxValueNameLen, &nMaxValueLen, NULL, NULL);

    if (ERROR_SUCCESS != lResult)
    {
        _tprintf(_T("Failed to RegQueryInfoKey()\n"));
        ShowErrorFromLStatus(lResult);
        RegCloseKey(hKey);
        return 2;
    }

    szDeviceName = (LPTSTR)malloc(nMaxValueNameLen + sizeof(TCHAR));
    if (!szDeviceName)
    {
        _tprintf(_T("malloc() fail\n"));
        RegCloseKey(hKey);
        return 3;
    }

    szFriendlyName = (LPTSTR)malloc(nMaxValueLen + sizeof(TCHAR));
    if (!szFriendlyName)
    {
        free(szDeviceName);
        _tprintf(_T("malloc() fail\n"));
        RegCloseKey(hKey);
        return 3;
    }

    _tprintf(_T("Found %d serial device(s) registered with PnP and active or available at the moment.\n"), nValues);

    for (DWORD dwIndex = 0; dwIndex < nValues; ++dwIndex)
    {
        dwType = 0;
        nValueNameLen = nMaxValueNameLen + sizeof(TCHAR);
        nValueLen = nMaxValueLen + sizeof(TCHAR);

        lResult = RegEnumValueW(hKey, dwIndex, 
            szDeviceName, &nValueNameLen,
            NULL, &dwType, 
            (LPBYTE)szFriendlyName, &nValueLen);

        if (ERROR_SUCCESS != lResult || REG_SZ != dwType)
        {
            _tprintf(_T("SerialPortEnumerator::Init() : can't process registry value, index: %d\n"), dwIndex);
            ShowErrorFromLStatus(lResult);
            continue;
        }
        _tprintf(_T("Found port \'%s\': Device name for CreateFile(): \'\\.%s\'\n"), szFriendlyName, szDeviceName);
    }

    free(szDeviceName);
    free(szFriendlyName);
    RegCloseKey(hKey);
    return 0;
}

Program output on my laptop:

Found 1 serial device(s) registered with PnP and active or available at the moment.
Found port 'COM23': Device name for CreateFile(): '\.\Device\BthModem0'

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Download uc browser for windows 7 32 bit
  • Wifi channel windows 10
  • Swap windows 10 настройка
  • Не устанавливается windows 10 ошибка 0x80070570
  • Актуальная версия itunes для windows