Microsoft's Satya Nadella must be wondering what more he has to do to impress China's leadership.

Nadella and his predecessors have done quite a bit already. Back in September, for example, Nadella not only played host to Chinese President Xi Jinping and his chief Internet censor at Microsoft headquarters near Seattle, but established a partnership to customize Windows with a state-owned defense contractor once called "the hi-tech heart of China's military."

Rather than giving thanks for Nadella's efforts, China announced last week that it was doubling down on a 2014 antimonopoly investigation into the company.

The actual charges are vague — state media claimed that Microsoft had caused "incompatibility problems" by not fully disclosing unspecified information related to Windows — but the import of the charges isn't. More than 20 years after entering China, Microsoft has earned little but suspicion for its efforts to play ball with the government. For U.S. tech companies with similar ambitions, Microsoft should serve as a cautionary tale.

This wasn't how it was supposed to work out.

In 2007, Bill Gates told Fortune that he expected China to be Microsoft's biggest market, "though it might take 10 years." The comments came during a visit to Beijing, during which Gates was given an honorary degree from Tsinghua University (only the 13th granted in the school's then 82-year history) and visited with four members of China's Politburo. A year earlier, then-Chinese President Hu Jintao, during a visit to Gates' Seattle compound, told the software magnate that he used Microsoft's software every day.

It must have felt like the company had turned the corner on the ugly early days of its operations in China. When Microsoft officially entered China in 1992, Windows and Office were already dominant. However, thanks to piracy (copies of Windows cost around $1 in most big cities during the early 2000s) and the government's unwillingness to crack down, the company wasn't making money on its market share.

So Microsoft took the nonsensical approach of suing Chinese firms violating its intellectual property — and lost. Meanwhile, it tried to sell full-priced software in a country where a legit copy of Windows exceeded many monthly wages.

By the late 1990s, it was clear that a new approach was needed. Craig Mundie, then Microsoft's chief research and strategy officer, told Fortune that the company's "business practices and our engagement did not reflect the importance of having a collaborative approach with the government."

In short order, Henry Kissinger was hired to smooth over ruffled government feathers and Microsoft officials began making regular visits. Meanwhile, the software company's online sites began censoring according to Chinese government guidelines (they continue to do so). In parallel, Microsoft opened a major research center in Beijing and — in 2003 — signed a pact to reveal the Windows source code to the Chinese government.

That last step was particularly important to Chinese authorities who've long worried that Windows and other U.S.-authored programs contain backdoors that could allow attackers into their computer systems. But having access to the source code wasn't enough, it turns out.

Microsoft is now customizing Windows security to the specs of Chinese government clients (a diplomatic cable released by WikiLeaks revealed that Chinese government hackers had used the source code in their hacks on Google). Last month, a Chinese state news outlet cited the latter development "as an improvement in the American company's relationship with the Chinese authorities" after a disastrous 2014 during which China launched its antimonopoly investigation of the company.

Alas, the improvement has been short-lived, as evidenced by the case's resumption. This should come as no surprise to Microsoft, however. For more than a decade, China has made clear its desire to develop domestic alternatives to U.S. technology, including Windows and Office.

Microsoft can hope that continued collaboration will ultimately build the trust necessary to overcome that ambition, and the paranoia over security that inspires it. But so far, Microsoft has little to show for two decades of effort beyond market share that it still can't monetize (it's giving away Windows 10 for free).

Motley Fool claims that China "consistently" produces less than 10 percent of the company's earnings (Microsoft doesn't break out China earnings), and its last quarter, Microsoft predicted further sales declines in China, driven in part by government policies designed to curb the use of foreign software. Bill Gates' 2007 prediction that China would be the company's biggest market is — for the foreseeable future — a diminishing dream.

That failure should give pause to other U.S. tech companies, from IBM to Apple, currently under pressure to cooperate with the Chinese government to build or maintain their presence in China. If Microsoft's experience is any guide, they will end up giving away far more than they receive.

Long-term, they're probably better off focusing their investments and efforts on emerging economies that aren't committed to putting them out of business. China's market might be big, but it's not for them.