Passing arguments to thread

How can i pass function arguments if i create thread by using CreateThread() function?
Thanks
I really need to do this because my program stops responding. I have a function that copies a floppy but it takes at least 1 minute to complete and program crashes :-( . This is peace of my callback function:
...
case IDOK:
CopyDisk(filepath,drive); break;
...
I have to create a new thread and then function won't stop my program...
http://msdn.microsoft.com/en-us/library/ms682453.aspx <--- CreateThread
http://msdn.microsoft.com/en-us/library/ms686736(VS.85).aspx <--- ThreadProc

Note the lpParameter argument in CreateThread. What you give for that argument is simply passed to ThreadProc as it's argument:

1
2
3
4
5
6
7
8
9
10
11
12
DWORD WINAPI MyThread(LPVOID p)
{
  MyObject* obj = static_cast<MyObject*>(p);

  // use 'obj' here
  // obj == &MyObject
}


//---------

CreateThread(0,0,&MyThread,    &MyObject    ,0,0);
Topic archived. No new replies allowed.