If a device is connected you can communicate using the device specific protocol. If this fails, there is no device connected or it is a different kind of device.
What do you mean by serial port emulator?
If you mean a kind of software that emulates a specific device you can usually not determine by communication and timing if a software emulation or a real device is used because the goal of such emulators is to simulate the behaviour of a real device including the timings.
Or do you refer to a converter like an USB to serial converter?
In both cases (software emulator and converter) you can query the system information for the serial port to check if it is a "real" port or a virtual one. The CodeProject article
A Useful WMI Tool & How To Find USB to Serial Adaptors[
^] provides an example application to query the information which can be used to decide if a port is "real" or virtual.
The above uses WMI to query the information. See
c# - How to open a serial port by friendly name? - Stack Overflow[
^] for a solution using the SetupAPI. The
SPDRP_SERVICE
property will contain "Serial" for physical ports and other strings for virtual ones.