First of all your computer needs to have a bluetooth receiver and you are going to need a sensor bar. A USB Wii sensor bar can be had on Ebay for just under $10. Then you will need a piece of software called "Touchmote". After installing and launching Touchmote you just need to sync the Wiimote you are using and you now can use your Wiimote as a mouse or to emulate an Xbox 360 controller.
For example on ReDream (Dreamcast emulator) I had to set it to mouse cursor mode to get it to work properly. But in MAME it works better in the Xbox controller emulation mode. Touchmote also allows you to customize all buttons on the Wiimote/Nunchuck/Classic Controller to anything you want.
It is really cool to finally be able to play old lightgun games with a gun controller instead of the mouse. I forgot to mention a Wii gun is highly recommended. You can obviously just use the Wiimote on it's own which is step up from using the mouse. But for the full lightgun experience you need a Wii gun.
This is the one I have. The Nyko Perfect Shot

I bought mine back when the Wii was still current and it was $15. It is a pretty nice gun controller but it is literally just a plastic gun that holds the Wiimote. When you pull the trigger it pushes the B button in on the Wiimote. The only bit of electronics in it is just passthrough so you can plug the Nunchuck into the bottom of the gun. Years later I picked up another one at Goodwill for $0.99.
It is much better than the official Wii Zapper.

I always thought that was a stupid design. It doesn't even really look like a gun and having the nunchuck mounted at the back of it seems inconvenient. I'd much rather plug it into the bottom of the gun then have one hand to shoot and the nunchuck in my other hand to move around.
So has anyone here ever used Wiimotes on a PC for old lightgun games? To me it is one of the best ways to play these old games on a modern display since the large majority of lightguns won't function on a flatscreen television.