Collisions of Ar17+ ions with gaseous and solid targets at a few tens of keV/q probed by X-ray spectroscopy