There are no obligatory codes of behaviour when meeting The Queen or a member of the Royal Family, but many people wish to observe the traditional forms.
For men this is a neck bow (from the head only) whilst women do a small curtsy. Other people prefer simply to shake hands in the usual way.
On presentation to The Queen, the correct formal address is 'Your Majesty' and subsequently 'Ma'am,' pronounced with a short 'a,' as in 'jam'.
For male members of the Royal Family the same rules apply, with the title used in the first instance being 'Your Royal Highness' and subsequently 'Sir'.
For other female members of the Royal Family the first address is conventionally 'Your Royal Highness' and subsequently 'Ma'am'.