Contrast is key. You need the background to contrast, not too much though, with the gun itself.
You also want a camera with a macro mode that will let you take closeups. My Cannon digital Elph has a still-life button that lets you take awesome closeups indoors. It reduces the flash as well to compensate for taking a closeup.
As with all things photographic, take more than one shot. When I was big into black & white 35mm photography, I'd take a whole roll and only come out with maybe one great shot. Change the settings between shots; flash on/off, macro on/off, zoom in/out (you can always crop it later on the computer, and you'd be amazed at what zooming out can do to your light meter), etc.
This picture was taken indoors, with the "stil life" mode on, using the flash. I think the detail is pretty damn amazing.