Why would there be another way? To get the operating system's idea of something you ask the operating system using the mechanisms the operating system offers.

BTW: Nothing to do with MFC. This is straight Windows API code.