|MadSci Network: Chemistry|
Chemically there is no difference between the nitroglycerin used in dynamite and that used in heart medication. This is indicated by the fact that nitro pills are kept away from light (nitroglycerin is light-sensitive, like many nitrogen compounds).
Nitroglycerin is indeed an explosive, because of its almost perfect oxygen balance. This means that no outside source of oxygen is needed for complete combustion. Nitroglycerin decomposes explosively according to the reaction
Dynamite is safe to handle, which means it is not shock-sensitive, because the nitroglycerin is diluted with about 25% of an inert substance, diatomaceous earth. It takes a blasting cap to set off dynamite, but pure nitroglycerin can be set off by a jolt.
Medicinal nitroglycerin is non-explosive because it is far more dilute than dynamite. Take it from me, a chemist and the son of a pharmacist, that almost all medicines are given in a highly diluted form. For pills, this is often simply for ease of handling, since doses are typically in milligrams -- a rather small quantity of substance. In the case of nitroglycerin pills, there's another reason for the dilution besides convenience!
I am sorry that I can't help you with the mechanism of action, but the Merck Index gives the following references:
Try the links in the MadSci Library for more information on Chemistry.