Hello out there,
is there a way to find all COM ports which currently exist on a
Windows machine? IIRC I once had a twapi routine which could do that
but either I am wrong or I cannot find it anymore.
Any help will be greatly appreciated
Helmut
Using the registry package:thanks a lot - this was really helpful. Alas, it turned out that this
# 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'
Hello,
https://wiki.tcl-lang.org/page/serial+ports+on+Windows
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 970 |
Nodes: | 10 (2 / 8) |
Uptime: | 103:47:52 |
Calls: | 12,740 |
Calls today: | 2 |
Files: | 186,574 |
Messages: | 3,171,634 |