It works by measuring the drug molecules which are absorbed into the blood stream after the body processes the drug. These molecules are then absorbed by the hair follicle and built into the hair, which can then be analysed later on.
The procedure works by cutting the hair near to the scalp and then analysing the 4cm closest to the scalp. This reflects a period of approximately 90 days, but if a longer piece of hair is analysed then a longer history can be compiled.
Body hair may also be used to screen for drugs and (due to the slower growth rate of this type of hair) substances can be detected up to a year after consumption.
The standard test requires around 40-60 strands of hair, and the variations are dependent on the thickness of the person's hair.
The effectiveness of the drug detection depends on the drug in question, and the quantity and regularity of consumption. The marijuana screen is currently the least effective, being only as good as urine tests, while the other four drugs prove to be far easier to detect in hair samples.
To summarise: The drug molecules are built into the hair, and therefore the screens can detect it if marijuana was used regularly. However, these screens only focus on the last 90 days, so you only need to worry if you've taken it in that period of time.