We study a stochastic linear-quadratic optimal control problem with regime switching, random coefficients, and cone control constraint. The randomness of the coefficients comes from two aspects: the Brownian motion and the Markov chain. Using Ito's lemma for Markov chain, we obtain the optimal state feedback control and optimal cost value explicitly via two new systems of extended stochastic Riccati equations (ESREs). We prove the existence and uniqueness of the two ESREs using tools including multidimensional comparison theorem, truncation function technique, log transformation and BMO martingale. These results are then applied to study mean-variance portfolio selection problems with and without short-selling prohibition with random parameters depending on both the Brownian motion and the Markov chain. Finally, the efficient portfolios and efficient frontiers are presented in closed forms. Based on a joint work with Ying Hu and Zuo Quan Xu.