you are better of using a specific rear mech hanger bolt as it will clamp the hanger snugly to the frame . using some chain ring bolts can cause an issue, If the female part of the bolt is too long it wont clamp the hanger properly, and if the male bit is too long it protrudes towards the cassette and you can risk catching the chain on it.
better to use the correct bolt as they only cost pennies from any lbs anyways