Let K be an imaginary quadratic field different from $\open{Q}(\sqrt {-1})$ and $\open{Q}(\sqrt {-3})$. For a positive integer N, let K-N be the ray class field of K modulo $N {\cal O}_K$. By using the congruence subgroup +/- Gamma(1)(N) of SL2(DOUBLE-STRUCK CAPITAL Z), we construct an extended form class group whose operation is basically the Dirichlet composition, and explicitly show that this group is isomorphic to the Galois group Gal(K-N/K). We also present an algorithm to find all distinct form classes and show how to multiply two form classes. As an application, we describe Gal(K-N(ab)/K) in terms of these extended form class groups for which K-N(ab) is the maximal abelian extension of K unramified outside prime ideals dividing NOK.