DemulShooter is an invaluable utility for lightgun gaming on the PC. I think it was inspired by the earlier TroubleShooter program which did a similar thing.
What DemulShooter does is take the lightgun inputs that you generate and it inserts them directly into the memory of the arcade games that you are playing.
It does various other things like map buttons and enable hacks to remove the aiming icon etc on certain games.
It focuses on arcade titles but also runs on some PC games. It tends to not be necessary on console emulators that have their own lightgun support.
You can find DemulShooter at tis github repo:https://github.com/argonlefou/DemulShooter and instructions for the emulators and games that it supports can be found in its Wiki here https://github.com/argonlefou/DemulShooter
Most games work slightly differently as its coded for each one specifically – so do read the instructions thoroughly for each new game.
If you want to get further into it, this forum seems to be where most of the chat about it takes place and the dev is pretty active in it answering sensible questions and making updates where possible. http://forum.arcadecontrols.com/index.php/topic,149714.0.html