Hi
There are numerous solutions to this problem, you could write your own but there are plenty of scripts around on the web that do what you want.
Try this one:
http://evolvedcode.net/content/code_antihotlink/ or Google for 'stop hotlinking asp script'.
Tim Marshall