For the first time, we elaborated a method for the synthesis of pyrimidines containing an allomaltol unit. The suggested approach is based on the reaction of 2-(1-(dimethylamino)-3-oxo-3-arylprop-1-en-2-yl)-3-hydroxy-6-methyl-4H-pyran-4-ones with cyanamide. The photochemical behavior of the obtained pyrimidines was investigated. It was shown that for the hydroxy derivatives the main pathway of phototransformation is a 6π-electrocyclization of the 1,3,5-hexatriene system and subsequent [1,9]-Hsigmatropic shift leading to dihydrobenzo[h]pyrano[2,3-f]quinazolines. At the same time, for methylated analogues the photoreaction proceeds in two directions resulting in the formation of a mixture of the corresponding dihydrobenzo[h]pyrano[2,3-f]quinazolines and polyaromatic products. The obtained dihydro derivatives are stable compounds and do not undergo aromatization upon further UV irradiation. The structures of two of the dihydrobenzo[h]pyrano[2,3-f]quinazolines were confirmed by X-ray diffraction analysis. Based on the performed studies, a two-stage telescopic method for the synthesis of polyaromatic benzo[h]pyrano[2,3-f]quinazolines including the initial photocyclization of the starting pyrimidines and the final dehydration was proposed.