In extreme cases it's a lot like taking an extremely wild three year old to the dentist - neither the kid nor the dentist has any fun but I've found a few ways to get around that, though.
First, they do make actual devices for getting your dog to take his medicine. Believe me, though, my dog knows what a piller looks like just like he knows what a medicine bottle looks like.
He's been to the vet often enough for that, and I bet your dog has too! Still, pillers can definitely work for some dogs, especially dogs who aren't as detail oriented as my dog is.
The second possibility is to just poke and pray - that is, you put the pill at the back of the dog's mouth and try to keep his mouth shut until he swallows.
I've seen this work once or twice, but I've also seen a dog sit quietly with his mouth held shut for five minutes before running off to spit out the pill behind the couch!
In my opinion, the best way to pill a dog is to bribe him. Take the pill and wrap it in whatever kind of treat he likes best. Mine is fond of hot dogs, so I cut a little hole in the middle of a hot dog and tuck the pill in so it's completely covered.
You can also use cheese or liver - whatever your dog likes best, as long as it has a strong enough smell to cover the medicine. Keep it small, so he won't have to chew and find the pill inside, and he should gulp it right down - medicine and all! In my opinion, this is the easiest way to give a dog meds.