Ten years ago I wanted exactly the same functionality in Avenue in Arcview 3.x but there was not to much to do about it.
A few years ago I started using PostGIS and since it is Open Source there were new possibilities. Now PostGIS has this functionality in ST_Shortestline since version 1.5.
Here is a shortversion how to make it (In 2D):
There is two possibilities in 2D where you can find the shortest line (or distance)
1) Between a vertex point in one geometry and a vertex point in the other geometry
2) Between an edge in one geometry and a vertex point in the other
In 2D the shortest distance will not be between two edges (well, it can be if the edges is paralell, but then you will always get the same min distance between one of the vertex points and one of the edges)
So what you have to do is iterating through the vertex points and edges in the geometries and compare all combinations of vertex points and edges that is possible.
To compare the vertex points combinations you just use Pythagoras theorem
When you get the shortest distance (after testing all possibilities) your shortest line should be built from those vertex points.
When comparing vertex point to edge you can use the algorithm from part 1.02 of http://www.faqs.org/faqs/graphics/algorithms-faq/
to find the point on the edge that is closest to the vertex point in the other geometry
When you have that point you can do exactly like in the vertex-vertex case.
I am curious, does anyone know, in what gis-products is this functionality included?