Sujet : Re: Find all COM ports (Windows)
De : hgiese (at) *nospam* ratiosoft.com (Helmut Giese)
Groupes : comp.lang.tclDate : 14. Jun 2024, 16:09:18
Autres entêtes
Organisation : ratiosoft
Message-ID : <m0no6j18697c43pq4rivtd71cl3ld462tt@4ax.com>
References : 1 2
User-Agent : Forte Free Agent 1.93/32.576 English (American)
Hello Ralf;
Using the registry package:
>
# Retrieve actually available com-ports from Windows registry.
proc get_serial_ports_from_windows_registry {{hwpath 0}} {
set ComPorts [list]
#
# Get available com-ports from windows registry
#
package require registry
set serial_base "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM"
>
if {![catch { registry values $serial_base } values]} {
foreach valueName $values {
if {![catch {string trim [registry get $serial_base $valueName]} port]} {
if {$hwpath} {
lappend ComPorts "\\.\$port"
} else {
lappend ComPorts $port
}
}
}
set ComPorts [lsort $ComPorts]
}
return $ComPorts
}
>
HTH
R'
thanks a lot - this was really helpful. Alas, it turned out that this
wasn't my real problem, so I will probably be back shortly - but then
with another thread.
Thanks again and have a nice weekend
Helmut