>The money goes straight into the greasy hands of the politicians, and thence into Swiss bank accounts.
That may be mostly true but still, its politicians who are at least in-country and to some extent (if only via revolution) accountable to the populace. A foreign corporation has no accountability beyond the value of the in-country assets and it never will. Even the greasy politicians will want to live like kings and spend some of it in-country. Foreign corps will send the profit abroad, no question there.
I suspect the root of the problem is that capital is not mobile. When a company owns a mine, they have a local monopoly. How do "more capitalists flood in" to get a share of the super-normal profits if there is a legal monopoly there?
Ultimately, the best thing for the country is to develop its own processing skills. Large corporations know this and keep strict division of labour, not (I think) only for efficiency, but to prevent skills from leaking between areas. Someone did an analysis of the iphone production costs and worked out that making it all in the US would cost less than an extra $5 per unit. Why go to all that trouble to offshore? Perhaps for the extra profit, but I suspect its more about avoiding tax by splitting up the industry and ensuring that a manufacturing industry isn't built up in the US where business skills and capital are plentiful. That would make a new challenger more likely. Far better to make it difficult for new entrants by making sure you have to be a multinational to even enter the game. There is a good reason McDonalds dumbs down the running of its outlets. It makes everyone easily replaceable. Do you really think the resource extraction industry doesn't do the same?
There is also a national problem. If prices rise for the raw or nearly raw materials, the western companies lose profit. That means lower pensions, higher-priced goods. Is that what we want? Do you think our own governments would push for that? What happens when all those imported goods cost a great deal more. Wealth is not really about increasing the size of the pie, its about pie distribution. You are only wealthy compared to poor people. The number of zeros at the end of your bank balance is not relevant. Increased efficiency does lead to greater wealth, but that is process efficiency (actually doing things better) not capital efficiency (increased ROI, usually by cutting costs, most often labour costs). Economists tend to over-simplify and conflate the two.
I don't think its just developing countries which fall foul of all this. Australia does very little processing of its own raw materials. Most of it is shipped to China and the result re-imported. Why? I suspect not for labour-cost reasons alone, though Australian labour is grossly over-priced. Processing raw materials is a capital-intensive, bulk-reducing process. Cheap Chinese labour is unlikely to make much of an impact. However, it would be very hard to avoid Australian tax by processing locally and selling something valuable. It all becomes quite easy when the goods disappear offshore.
As to a solution, the best one I can think of is to encourage local processing. Nationalisation might be one way of controlling the goods, but rather than purely taxation, I'd consider licenses for extraction to be based on building up local processing and local training. Create a local industry which knows how to process sand into semi-conductors, obtain plastic or gas from coal and oil. If you don't do the work yourself, you don't get the profits. There is a place for division of labour, but it needs to be carefully monitored because it will keep the workers poor (and tax receipts down) and may need breaking.