Q:

How to Return a vector to Windows thread function?

I have written a library which comprises of function and two thread functions. From the user program I will call the function inside the library with Drive id as parameter. The function creates threads according to no of Drive Id I have given. Then this thread function will process the drive getting list of folders from the drive and put it in a queue. Once it finishes it will call certain amount of threads (which i initialized with MAX_Threads) and these child threads will process the queue and put list of files inside the drive in their corresponding vector. Now my problem is I have to return these vector to the statement which called the library. I referred through many sites but i didn't got the intended result.
The snippet which I implemented is..
ListFiles(string DriveId)
{
    loop(no of drives)
        create Threads
}
DWORD WINAPI FileList::ParThread(LPVOID s)
{
    //Process Drive
    directories.push_back(path + "\\" + ffd.cFileName); //global queue 
    //it will be locked and then inserted and released by each thread

    loop(Max - threads)
        CreateThreads
}
DWORD WINAPI FileList::List(LPVOID s)
{
    //create vector local to each thread
    //create local queue that copies values from global queue and processing occurs in local queue
    //inserts file name into vector

}

Now I want to return these vectors to the statement which called the function ListFiles which is in library.

A:

The library function can create the vector and pass its address in the LPVOID thread parameter. If you need multiple vectors put them all in a struct and pass the address of the struct in the LPVOID thread parameter.

