We present a rigorous solution of a two-dimensional problem of stationary electromagnetic plane wave diffraction by a slot in a perfectly conducting screen having finite thickness in the presence of a plane dielectric layer behind the screen. For obtaining this solution, the method of additive regularization of singularities for field diffraction integrals is developed. This method is suitable for the cases of transparent, absorbing and amplifying dielectric. It reduces to explicit extraction of singularities in the form of supplementary singular integral terms, which describe waveguide modes of a dielectric layer. On the bases of the obtained solution, the conditions of optimum diffraction excitation for such modes are investigated in dependence of geometrical parameters of the problem for the cases, when these parameters are of the order of the radiation wavelength.