You are marginally reducing their cost of capital.
All finance is indirect. Particularly at small scale.
> Unless you're an early investor or IPO participant
Plenty of IPOs are entirely secondary. And public companies regularly raise money via at-the-market offerings, where a random trader may wind up cutting a cheque to the corporate treasury. (I’ve been a seed investor and IPO investor. My effects on the outcome were rarely singularly meaningful.)
In a large offering, a small IPO investor has about as much direct effect on the outcome as someone buying the pop publicly. In aggregate, however, their actions are meaningful and productive.
Put another way: contrast two economies, one in which most capital is tied up sports gambling (negative-sum game), the other in which it’s in equities (positive-sum long term), one will outperform the other.
MSFT goes up a tiny fraction when you buy. That means MSFT employees with stock grants get a tiny "raise" courtesy of you and with no cost to the company. Microsoft can also use their more expensive stock to make acquisitions. So you are contributing to the company's productive use in at least 2 ways if you buy its stock.
Buying MSFT doesn't meet the criteria to be called gambling, for me.