Usually, the injectors contain two pins. One pin is connected to the ECU. The ECU sends a pulsing ground to the injector, closing circuit. This lets the injector's solenoid get charged. The magnet on the plunger is attracted, opening the valve. The high pressure in the rail starts fuel injection at a high velocity when the valve opens.
When the plunger rises, it opens a valve and the injector sends fuel just upstream of the intake valve, or straight into the cylinder. The first system is called multiport fuel injection and the latter is called direct injection.
The ECU decides the amount of fuel to inject into the cylinders to make the mixture stoichiometric.