This does quite a lot of what you need. It breaks groups of adjoining
polygons into polylines with the 2 adjacent county names as fields, and the
lengths of common polylines.
If a linework output region is set to –1, then it means sea or
estuary.
I have provided a test set of English counties, the mbx and the code ( if
you need to tweak or adapt it).
First run; load up counties map and select all of them.
Press left button and;
Indicate on the dialog which field to use as identifier...County.
Set the match value as 1m (max)
Identify the output table.
Analyse the output table (Linework)
Good Luck