Code:
struct THREADPARAMS
{
int iParam;
void *pParam;
long lParam;
};
DWORD ThreadProc(void *p)
{
THREADPARAMS *pars = (THREADPARAMS)p;
pars->iParam...
// ...
delete pars;
}
void func()
{
HANDLE hThread;
THREADPARAMS *pars = new THREADPARAMS;
pars->iParam = 3;
pars->pParam = &something;
pars->lParam = 2348329;
hThread = CreateThread(ThreadProc, pars);
}
The way this is written there is one limitation: once CreateThread is called the creating thread may not access pars anymore in any way since it can' t know when the other thread finishes and deletes the parameters. If you still need the access you must think if a different way to avoid a leak.