Cos from f2 to h4 for spouse/

I am currently in F1 stem extn(till March 2018).My H1b application got picked up in lottery.I didn’t apply H4 for my spouse as my employer didn’t offer it.can I apply once my H1b is approved?How long can my spouse stay legally on F2 visa? Do I have to apply for H4 in US or Can I apply in India once my visa got approved?