Shared Serial Ports - Working with Windows registry

To share serial ports you must create corresponding keys in Windows registry. There are two ways to accomplish this task: creating registry file and importing it to Windows registry or manually creating the necessary entries using regedit or WinAPI directly from your application.

  1. The first way is better for automated process. You have to create text file with specified key-value pair beforehand and update Windows registry by executing REGEDIT -registry filename command. Format of the file (key-value pairs) will be described later on this page. The next step is to import this file into Windows Registry. This can be done by executing REG IMPORT filename.reg command.
  2. Another way is manual Windows Registry manipulation. Launch the Registry Editor program (Start ->RUN... -> type in "regedit" in the invoked window). This will open the program to work with registry (Registry Editor). At the left side of the program window you will see a tree-like folder structure. You need to go to the folder named HKEY_LOCAL_MACHINE. Then go to the directory SOFTWARE, in which you may create your own folder, where new entries will be saved (for example, create folder named "SharedSerialPorts"). To do this right-click the folder directory and select "New -> Key" from the drop-down menu. So, the complete path would be as follows: HKEY_LOCAL_MACHINE\SOFTWARE\ELTIMA Software\SharedSerialPorts

Let's take a closer look at the registry options:

To share serial ports in a system you must create the following key: HKEY_LOCAL_MACHINE\SOFTWARE\ELTIMA Software\SharedSerialPorts\.

  • HKLM\Software\ELTIMA Software\SharedSerialPorts
    • Shared Port Name
      • Permissions
        • List custom permissions for programs
      • Port settings

where HKLM\Software\ELTIMA Software\SharedSerialPorts is the main container key that stores all configuration info,

"Shared Port Name" is the key that has to be the same as the name of the port you are about to share (for instance, "COM1"),
"Permissions" is the key that stores all necessary entries to describe the programs, that have custom permissions, different from the default (R, W),
"List custom permissions for programs" is the list of the applications that have settings other than default. This list has to stick to the following syntax:

Variable name Full path and permissions
Contents (DWORD) By default the value is Read|Write (0x03)
Read - 0x01
Write - 0x02
Control - 0x0

and PortSettings is a string of 4 or 5 items, separated by comma. For instance:

nBaudrate,cParity,nDatabits,nStopBits,cFlowControl

  • nBaudRate

    Defines serial port baudrate. Possible values are: 110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 56000, 57600, 115200, 128000 and 256000. By default, 110 value is taken.

  • nDatabits

    Defines data lengths in a packet. Possible values are: 5, 6, 7 and 8. Default value is 7 bits.

  • cParity

    Defines parity is one of the following values: (E)ven, (O)dd, (M)ark, (S)pace, or (N)one. By default (N)one is taken.

  • nStopBits

    Defines a number of stop bits. Possible values are: "1", "1,5" and "2". Default value is "1".

  • cFlowControl

    Defines flow control value. Possible values are: Hardware (P), Xon/Xoff (X) and None. Default value is None.

PortSettings parameter could be empty, which means that dynamic connection parameters will be used instead.

Examples:

[HKEY_LOCAL_MACHINE\SOFTWARE\ELTIMA Software\SharedSerialPorts\COM2]
"PortSettings"="9600,N,7,1" - static Baudrate 9600, no parity, 7 data bits. 1 stop bits, no flowcontrol
"PortSettings"="" - Dynamic


[HKEY_LOCAL_MACHINE\SOFTWARE\ELTIMA Software\SharedSerialPorts\COM2\Permissions]
"C:\\Program Files\\Eltima Software\\Advanced Serial Port Terminal\\Terminal.exe"=dword:00000007
"C:\\Program Files\\Windows NT\\hypertrm.exe"=dword:00000001