Structures of CoNiZ (Z=Si, Sn, Sb, Ga) alloys have been investigated. We found that CoNiZ alloys have B2 structure with Z=Sn or Sb, but when Z=Si, the structure is fcc γ phase. When B2 structure coexists with γ phase in CoNiGa alloys, γ phase affects the temperature of martensitic transformation greatly. The structure of the alloy is determined by both the electron concentration and the size effect. The coexistence of two phases in the CoNiGa alloys can be changed by various heat treatment conditions. These results indicate that the martensitic transformation behaviors can be adjusted just by heat treatments, other than by modifying the composition as being done conventionally for other ferromagnetic shape memory materials.