Even though the market has changed, when it comes to how to invest in computers, there's still one obvious answer.

When it comes to the desktop market, Microsoft (MSFT -2.43%) still has a commanding share with its Windows operating system (OS). Yes, Apple (AAPL 0.56%) has a piece of that market, but at just under 4%, it's a niche player.

If you want to invest in computers -- even as that market has lost share to tablets and phones -- Microsoft remains the best way to do that. The company remains the dominant player in the computer space while also positioning its OS for the next generation of computing.

A chart of desktop market share

Windows remains the clear leader in desktop computer market share. Data source: Netmarketshare.com.

The PC business has been slipping

Personal computer (PC) sales have been falling for five years, according to data from Gartner. In Q2 2017, total shipments dropped to 61.1 million units, a 4.3% drop from the same period a year ago. The total was the lowest for a quarter since 2007.

"Higher PC prices due to the impact of component shortages for DRAM, solid-state drives, (SSDs) and LCD panels had a pronounced negative impact on PC demand in the second quarter of 2017," said Gartner Analyst Mikako Kitagawa in a press release.

While Microsoft itself is not one of the top PC vendors, the vast majority of those sold use Windows. In fact, other than Apple, which had just under 7% of the market, all the other companies on the list use Windows. The Gartner data includes sales of desk-based PCs, notebook PCs, and ultramobile premiums such as Microsoft Surface, but not Chromebooks or iPads. 

A Microsoft sign on its corporate campus

Microsoft has managed to keep Windows relevant. Image source: Microsoft.

Microsoft's plan for Windows

The reason Microsoft is the smart way to invest in computers over HP and Lenovo, which each sold roughly 20% of the PCs shipped, is that Microsoft looks more prepared for the next generation of computing. The company largely missed out when it came to smartphones, so it has invested to make sure that won't happen when it comes to the internet of Things.

Microsoft has engineered Windows so it can run everything from a fully functioning computer to a smart-home device. That gives the company an edge when it comes to next-generation computing, because it has one platform that can power a wide range of devices and functionality.

In 2015, Microsoft's Windows chief, Terry Myerson, predicted that Windows 10 would be on 1 billion devices in three years. In July of this year, about two and a half years after that prediction was made, CEO Satya Nadella said it was halfway to that goal, CNBC reported.

What's next for Microsoft?

Still, while the timing may be off, it's very clear that the future of computers remains mostly Windows-based. Apple will, of course, have its place in the computing world, but Windows looks as if it will remain the lead player.

The computer world has shrunk, but Microsoft has adapted to that. It's no longer a company that relies on the sale of PCs, but it still owns that market, and it will continue to own the evolution of that business.

Since most companies probably won't be migrating to virtual-reality devices or abandoning the PC format anytime soon, Windows licensing remains a good business to be in. As that changes, Microsoft has shown that it can change, too, making it a smart way to invest in computers over the long term.