The Silicon Valley economy is hot these days, but U.S. tech firms are feeling a chill in China.

Anti-monopoly investigators have raided Microsoft's China offices, and the government has banned Windows 8 from state computers. San Diego-based chip maker Qualcomm may face more than $1 billion in fines for allegedly overcharging customersfor smartphone patent licenses. And the government is encouraging Chinese businesses to abandon IBM systems in favor of local products.

It seems that no large tech company is escaping government scrutiny.

Google services such as Gmail and Maps have been increasingly stifled this year by China's "Great Firewall" — the country's censorship and surveillance program — while Facebook and Twitter remain blocked on the mainland. Last month state-run TV aired a report on the iPhone's tracking feature that suggested the devices could be used to expose state secrets.

China says it's simply enforcing antitrust rules and looking out for national security. But the regulatory moves — coupled with increasingly heated rhetoric against Silicon Valley giants and strong calls by Chinese leaders for homegrown tech innovation — are raising fears of a tougher business climate and a new burst of protectionism.

U.S. tech companies are in the horizontal and vertical cross hairs. They're between a rock and a hard place right now.— Duncan Clark, chairman of BDA China, a Beijing investment advisory firm

"U.S. tech companies are in the horizontal and vertical cross hairs," said Duncan Clark, chairman of BDA China, a Beijing investment advisory firm specializing in the tech sector. "They're between a rock and a hard place right now."

It's not just U.S. tech firms like Microsoft and Qualcomm feeling the pressure in China. These days, foreign companies of all kinds — including Japanese and German carmakers and European drug manufacturers — are being ensnared in anti-monopoly investigations.

A number of experts say that's the natural result of China ramping up enforcement of its anti-monopoly law, which is just 6 years old.

"China has been way behind the West in terms of antitrust law, but they're rapidly accumulating more experience in interpreting and enforcing the law," said Huang Yong, a professor at Beijing's University of International Business and Economics and member of the State Council's anti-monopoly committee advisory panel.

But the Chinese government is casting high-tech companies as a particular threat as the two countries trade cyberspying and hacking allegations.

China's suspicions about American companies were heightened in the wake of the Edward Snowden revelations, Clark noted, and Beijing is furious about Washington's allegations that China's military is stealing secrets from U.S. firms.

Meanwhile, the state-run media have been bashing Silicon Valley stars for months.

"American companies including Apple, Microsoft, Google, Facebook, etc. are all coordinating with the Prism programto monitor China," the Communist Party mouthpiece, People's Daily, said about the National Security Agency's electronic surveillance data-mining program in June. "To resist the naked Internet hegemony, we will draft international regulations and strengthen technology safeguards, but we will also severely punish pawns of the villain."

Last month, state-run TV aired a report on Apple iPhones' "Frequent Locations" feature (which enables Apple to track a handset's position) and cited a researcher saying the devices posed a serious risk. Anyone with access to the data could gain knowledge of "state secrets," the expert said — a charge that Apple denies.

China and the U.S. have long been mutually uneasy about the spread of technology from one to the other. The U.S. has imposed bans on telecommunications equipment from Chinese firms Huawei Technologies Co. and ZTE Corp., which American officials have deemed potential national security threats.

Since taking office last year, Chinese President Xi Jinping has repeatedly called on Chinese companies to innovate in areas such as robotics and artificial intelligence.

Although tech hardware firms are facing particular scrutiny in China, more foreign social media services are also being locked out of the country.

Government authorities have long seen any overseas-based message service beyond the reach of its censors as a potential danger, and years ago blocked Facebook and Twitter from the mainland.

This summer, South Korea's KakaoTalk messaging service and a similar product from Japan called Line were blocked in China. China has experienced a wave of recent bombings and knifings, and authorities said separatists and terrorists could be using such services to foment unrest.

Limiting market access can have major financial consequences. China's economy is the world's second-largest, and the Chinese consumer market has huge potential for American tech firms that can stay on the government's good side.

Apple reported nearly $6 billion in revenue from the greater China region, which includes Hong Kong and Taiwan, in the quarter ending June 30, up 28% from a year earlier.

But other U.S. tech companies are struggling in the market. Microsoft has made only limited progress reining in rampant piracy of its software. Qualcomm makes half of its revenue in China, but said in its last quarterly report that it was having problems collecting licensing fees from device makers.

Options are limited for U.S. tech companies hoping to gain a bigger foothold in China, and executives have largely remained tight-lipped about their plans.

"They'd all like to have a China strategy, and you hear every now and then about attempts in that regard, but where they're banned, they're banned," said Brian Wieser, an analyst at Pivotal Research Group. "There's not too much they can do about it."

One work-around is to bring their secondary services to China. For instance, although Google's core search engine is largely inaccessible in China, its online advertising business performs well.

"It is possible to exist in China even if your flagship service does not," Wieser said. "There's always a way to capitalize on growth in related activities in China, but it may not be through the primary service that we know of in the United States."

That appears to be the case with Facebook, which, despite being censored in China, is looking to open a sales office in Beijing to woo local advertisers.

The Menlo Park, Calif., tech company didn't return requests for comment, but Chief Operating Officer Sheryl Sandberg said during a recent earnings call that Facebook had been "studying and learning about China for a number of years, and we remain very interested."

Still, many China-based analysts remain rather bearish on the prospects for U.S. tech firms in the mainland in the near term.

"I've been thinking already for quite a while that China is closing again and is becoming fairly hostile to international influence," said Anne Stevenson-Yang, director of J Capital Research in Beijing.

China's Communist leaders have "called open season on foreign companies," Yang said, and "are obviously willing to sacrifice commercial benefits to maintain the primacy of the party and their political position."