They use a theorem prover to validate drivers.
Static analysis is a enforced on the Windows source code via the Security Development Lifecycle Checks.
VC++ has quite a few security options that are enabled and used to compile the kernel.
After the whole Windows XP Swiss cheese episodes they ramped up quite a few security processes.
Windows 10 allows for individual application sandboxing.