Depends—at many teaching institutions, a textbook totally counts. This is one reason a lot of textbooks are produced by professors at what a lot of CC types think of as “second-tier” institutions—those are the places where the incentives reward writing textbooks.
Basically, though, the profit from textbook sales goes to the publishers. The bookstore gets a little bit, the author gets a little bit, but for each of those, aside from a very, very few cases that sometimes get trotted out to be treated as if they were the norm, it’s only a very little bit.