Using raw IR involves accessing the IR port and handling the connection as a serial port with IR hardware attached. An application has the most control of IR communications using this non-IrDA-compliant method. Without this standard, it is possible for signal collisions to occur between devices during a data exchange. Also, it is possible to lose data when the infrared beam is broken, such as when someone walks between the two devices. The application must detect these error conditions and correct them.
Before using the IR port, an application must identify the COM port attached to the IR transceiver. The HKEY_LOCAL_MACHINE\Comm\IrDA key specifies the port. Use the RegOpenKeyEx function to open this key. Then use the RegQueryValueEx function to get the value of the Port subkey, which is the port number.
If a Windows CE–based device shares serial hardware with the IR port and the serial port, an application must instruct the COM driver to route data through the IR port. To do this, use the EscapeCommFunction function with the dwFunc parameter set to CLRIR. Now use the standard serial communications functions to transmit and receive data.