I am trying to write a program that uses an arduino mega and a FTDI-based USB to RS485 adapter.
I want to make the program user-friendly, thus I don\'t wont the user
I don't have a USB<->RS485 adapter, but I suspect they don't fall into the "serial port" category (which seems reserved for RS232 interfaces), which could be the reason why they don't appear among the Win32_SerialPort query results.
To detect the connection of and Arduino board I look into this registry key:
HKLM\HARDWARE\DEVICEMAP\SERIALCOMM
for entries like
\Device\VCP0
(VCP is the prefix to look for).
Maybe you can look into this registry key too, or watch its parent key, DEVICEMAP, and see what happens when you connect the FTDI RS485 adapter. Detecting a change in one of these registry keys contents should be straightforward at that point.
HTH