From 0ffbb1001d9c70bafde802d86984ce8f6705ea4f Mon Sep 17 00:00:00 2001
From: zmatsuo <6488847+zmatsuo@users.noreply.github.com>
Date: Mon, 1 Apr 2024 00:02:06 +0900
Subject: [PATCH] =?UTF-8?q?COM=E3=83=9D=E3=83=BC=E3=83=88=E3=81=AE?=
=?UTF-8?q?=E4=B8=80=E8=A6=A7=E3=81=AB=E7=84=A1=E5=8A=B9=E5=8C=96=E3=81=97?=
=?UTF-8?q?=E3=81=9FCOM=E3=83=9D=E3=83=BC=E3=83=88=E3=81=AF=E5=90=AB?=
=?UTF-8?q?=E3=82=81=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E3=81=97?=
=?UTF-8?q?=E3=81=9F=20#164?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
doc/en/html/about/history.html | 1 +
doc/ja/html/about/history.html | 1 +
teraterm/common/comportinfo.cpp | 16 +++++++++++++---
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/doc/en/html/about/history.html b/doc/en/html/about/history.html
index 1fa7b1af6..bfa222286 100644
--- a/doc/en/html/about/history.html
+++ b/doc/en/html/about/history.html
@@ -42,6 +42,7 @@
YYYY.MM.DD (Ver 5.3 not released yet)
Right-click(paste) is not disabled even when SelectOnActivate is off.
allow users to select creating automatic backup or not by IniAutoBackup when overwriting the ini file.
VTFontSpace can be used to adjust to narrow the space between characters.
+ Disabled COM ports are not included when making list of COM ports.
diff --git a/doc/ja/html/about/history.html b/doc/ja/html/about/history.html
index d25cef86e..4274ed887 100644
--- a/doc/ja/html/about/history.html
+++ b/doc/ja/html/about/history.html
@@ -42,6 +42,7 @@ YYYY.MM.DD (Ver 5.3 not released yet)
SelectOnActivate が off でも右クリックによる貼り付けは行われるようにした。
iniファイルを上書きする際に自動バックアップを作成するかどうかを IniAutoBackup で設定できるようにした。
VTFontSpace で負の値を設定できるようにした。
+ COMポートの一覧に無効化したCOMポートは含めないようにした。
diff --git a/teraterm/common/comportinfo.cpp b/teraterm/common/comportinfo.cpp
index 6c2879855..9e592003f 100644
--- a/teraterm/common/comportinfo.cpp
+++ b/teraterm/common/comportinfo.cpp
@@ -29,6 +29,7 @@
#include
#include
#include
+#include
#include
#define _CRTDBG_MAP_ALLOC
#include
@@ -197,8 +198,8 @@ static BOOL GetComPortName(HDEVINFO hDevInfo, SP_DEVINFO_DATA *DeviceInfoData, w
* HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{GUID}\0000
*
*/
-static void GetComPropartys(HDEVINFO hDevInfo, SP_DEVINFO_DATA *DeviceInfoData,
- wchar_t **friendly_name, wchar_t **prop_str)
+static void GetComProperty(HDEVINFO hDevInfo, SP_DEVINFO_DATA *DeviceInfoData,
+ wchar_t **friendly_name, wchar_t **prop_str)
{
typedef struct {
const wchar_t *name;
@@ -441,6 +442,15 @@ static ComPortInfo_t *ComPortInfoGetByGetSetupAPI(int *count)
break;
}
+ // check status
+ ULONG status = 0;
+ ULONG problem = 0;
+ CONFIGRET cr = CM_Get_DevNode_Status(&status, &problem, DeviceInfoData.DevInst, 0);
+ if (cr != CR_SUCCESS || problem == CM_PROB_DISABLED) {
+ // ステータス取得に失敗 又は デバイスが無効の時
+ continue;
+ }
+
wchar_t *port_name;
if (!GetComPortName(hDevInfo, &DeviceInfoData, &port_name)) {
continue;
@@ -453,7 +463,7 @@ static ComPortInfo_t *ComPortInfoGetByGetSetupAPI(int *count)
// 情報取得
wchar_t *str_friendly_name = NULL;
wchar_t *str_prop = NULL;
- GetComPropartys(hDevInfo, &DeviceInfoData, &str_friendly_name, &str_prop);
+ GetComProperty(hDevInfo, &DeviceInfoData, &str_friendly_name, &str_prop);
ComPortInfo_t *p =
(ComPortInfo_t *)realloc(comport_infos,