What I want to do?
I just want to creat a child thread,which counts the child folder numbers in some folder with recursive traversal method. The PATH is parameter of my recursive function
void myclass::FolderNum(LPTSTR path)
{
HANDLE hFile;
...
findfirstfile(...);
...
do
{
if()
{
... FolderNum(path);}
}while(findnextfile(...));
closefile(hFile);
}
Here the problem comes!
If put in main thread, my code runs well. While in child thread, it gets sick!!! When debuging, I found the parameter of my recursive function-PATH-were not been pushed into the thread stack,or at least, there's something wrong when PATH pushed. Because the PATH appears in Garbled characters when my code jump out from first recursion
By the way,
VS2008, WTL, all my functions except thread callback function are member functions of a class(it means, my thread callback function was a friend function of this class.)
So...
1、Any advise? vs2008 debugger problems? Should I use WinDBG? Is there better tools for debugging multithread programs? Or,tips of thread stack especially child thread stack...
2、Thank you in advance.
3、Sorry for my poor English.
ADD:
//these codes are in a member function, creating a thread
TCHAR szCurrentPath[MAX_PATH];
GetCurrentDirectory(MAX_PATH,szCurrentPath);
dwFolders=1;
dwFiles=0;
nPos=0;
stepLenth=0;
threadpara *pa=new threadpara;
pa->hDll=hDll;
pa->myself=this;
pa->szf=szCurrentPath;
DWORD threadId;
HANDLE thr;
thr=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ThreadScan,(LPVOID)pa,0,&threadId);
//ThreadScan is the thread function.
void ThreadScan(LPVOID lpv)
{
Sleep(2000);
threadpara *p=(threadpara *)lpv;
myclass* first=p->myself;
LPTSTR current=p->szf;
HINSTANCE dll_unload=p->hDll;
first->FolderNum(current);
ExitThread(0);
}