the first viable answer is giving you the solution, except it doesn't work because the API has changed many years ago.
the second viable answer is telling you that you don't want to do that and it's certainly wrong to try.
the third viable answer is a guy advertising to use another library for just that. (Just because you use C++ doesn't mean you have boost or Qt available but fair enough).
The fourth viable answer is a guy advertising for his own library to solve that same problem. It may or may not be shameless advertising. The github link is dead half the time.
The topic is closed. It will never be possible to post the right valid answer to that problem.
Answers cannot be edited. They will rot forever and mislead an entire new generation.
I never ask questions in SO. To be honest, I'm not dissatisfied either, I just gave up. When I saw a question for which I knew the exact answer, I was unable to answer because... I don't know. I wasn't reputable enough to answer and I couldn't get a reputation because I couldn't answer. Or something like that, I don't remember or I don't care. I just google for answers.
So I would reconsider the "invariably". But that's just my two cents.