Oh, my goodness! Yes, I can see pills being a danger in homes and hospitals!
You're right, though. If your future dog is grown, he/she will come with their own food rules.
Although, you can gently encourage, and use positive reinforcement, an older dog to take food only from you. I picture laying groundwork by making a big deal of him/her taking food from you, or getting their dish. Then, dropping a piece of kibble on the floor (because it's a low level treat, unlike, say, a piece of chicken.) after he/she has eaten, and saying 'noooooo' or 'waaait' while blocking them from picking it up - you can put your foot on it, need be - then you getting it, and either handing them a treat, or dropping it in their dish, then praising when they take it.
You can add the 'off' command, and as they do well with it, make the item on the floor a higher level treat, so it's harder to resist. Also, you would want to make sure that a treat was ready to go, in your pocket, or treat pack. But, the treat that you give has to be a high level treat, too, to make it worth their while to ignore one for the other. Then, work up to putting something on the ground outside, etc.
It may not be foolproof, but it could give you time to get them away from something before they snorkel it one day. And, I've found that dogs of all ages enjoy learning new things, because it engages their minds, and gives them special time with their person, plus, let's not forget the key thing here, at the end of the day - they get treats! lol!
Love All Life, Thank You For Posting! :)