There are some applications which claim to be able to detect the temperature of various components inside your PC, for example: Speedfan. How do they detect the temperature without using any external tool?
There are sensors, spread all over your pc. They depend on the hardware you use, but almost every motherboard has a thermal sensor at the cpu socket. So all what those tools do is polling those sensors for information. You can do that on your own with a little bit of programming, for example by using WMI.