Quien is used for persons only. El cual and que are used for persons and things.
El agente a quien (or al cual) hemos escrito. The agent to whom we have written.
¿Son aquéllas las casas de las cuales me habló usted ayer? Are those the houses of which you spoke to me yesterday?
Me acuerdo de las personas y las cosas que usted ha mencionado. I remember the people and things that you mentioned.
El buque cuya tripulación ha desembarcado. The ship whose crew has landed.
El comerciante a cuyo hijo hemos conocido. The merchant whose son we have known.
NB: CUYO is not often used in colloquial speech and is often replaced by QUE but it's important to know the usage.
Tienen muchas fotos de España, cuya capital visitaron en 2007. They have many photographs of Spain, whose capital they visited in 2007. Ella es Rosa cuyos padres son Manuel y Teresa. She is Rosa whose parents are Manuel and Teresa.
No entendí lo que dijo. I did not understand what she said. Lo que dijo no significó nada. What he said doesn't mean anything.
María y Juan fue con quienes fui. María and Juan were with whom I went. Ellos fueron las personas con quienes viajamos. They were the people with whom we traveled.
Manuel es con quien Rosa se casó. Manuel is the man with whom Rosa married. El es artista con quien María se lleva tan bién. He is the artist with whom María gets along well.
Duque es el perro el cual adopté cuando tenía un mes de nacido. Duke is the dog which I adopted when he was one month old. Este es el premio el cual gané durante una rifa. This is the prize which I won during a raffle.
Ese cuadro fue un regalo de su yerno cuyo gusto es extraño. That picture was a present from her son-in-law, whose taste is strange. Este es el carro de Sofía cuyo color favorito es el rosado. This is Sofía's car whose favorite color is pink.