Hallo Tara
Den Comport ansprechen und auslesen ist kein Problem. Nun soll
der Anwender aus 4 Comports wählen am Anfang. Wie kann ich
denn Abfragen, ob der Comport verfügbar, und ob ein Gerät
angeschlossen ist?
Einfach Port als File öffnen und prüfen ob
der Fehlerstatus ERROR_FILE_NOT_FOUND ist.
vgl:
http://msdn.microsoft.com/library/default.asp?url=/l…
One thing to note about port names is that traditionally
they have been COM1, COM2, COM3, or COM4. The Win32 API does
not provide any mechanism for determining what ports exist on
a system. Windows NT and Windows 95 keep track of installed
ports differently from one another, so any one method would
not be portable across all Win32 platforms. Some systems even
have more ports than the traditional maximum of four.
Hardware vendors and serial-device-driver writers are free to
name the ports anything they like. For this reason, it is best
that users have the ability to specify the port name they want
to use. If a port does not exist, an error will occur
(ERROR\_FILE\_NOT\_FOUND) after attempting to open the port,
and the user should be notified that the port isn't available.
Aber Vorsicht:
http://www.codeproject.com/system/serial.asp
Most virtual COM ports have difficulties with the CancelIo
function. In some cases the process freezes completely (and
cannot even be killed by the task manager) and I have even
seen Windows XP systems reboot after calling CancelIo. Some
drivers can handle CancelIo for an overlapped ReadFile call,
but fail when canceling a WaitCommEvent request.
Um was genau handelt es sicht denn?
Grüße
CMБ