multiple arguments to CreateThread function

Aneesh Narayanan picture Aneesh Narayanan · May 15, 2012 · Viewed 11.2k times · Source

When I use the CreateThread API method, what do I need to do when I want to pass more than one parameter where LPVOID lpParameter is passed?

Answer

Attila picture Attila · May 15, 2012

You can create a structure that holds all relevant data and pass a pointer to an instance of that structure (filled with the appropriate parameters) to CreateThread()

In your thread creation function you will need to cast the LPVOID back to a pointer to your structure to use it.