|
Posted the above thread by mistake! Please ignore it (and check the one above it)
|
|
|
|
|
I'm writing a multi-threaded FTP sites and contents searching program using WININET lib. When I search the contents in a FTP site, I have to enumerate the files under a directory. But when I use MFC's CFtpFileFind class, it terminated with a error message at FtpFindFirstFile() when there're some thousands of files under the directory. I tried many times but it still failed. I can't solve this problem. Could someone give me some suggestions?
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
What's the error message?
Post some code.
--Mike--
http://home.inreach.com/mdunn/
Trillian: What are you supposed to do with a manically depressed robot?
Marvin: You think you've got problems. What are you supposed to do if you are a manically depressed robot?
|
|
|
|
|
Sorry, I'm using Win 2k Simplified Chinese version, so I don't know what the error message is in English. But I think it should be something like "0xxxxxx" instruction referenced to "xxxxxxxx" address error, the memory cannot be 'read'. Here is the content searching function:
void MultiThreadSearch::IterFind(
CFtpConnection *pFTP,
LPCTSTR szStrToFind,
LPCTSTR dircontent,
int maxdepth,
BOOL bOmit,
int index,
int depth)
{
MSG msg;
CStringArray csDirectories;
long directories=0;
BOOL bFlag=FALSE;
BOOL bNeedSearch=TRUE;
if(maxdepth!=-1&&depth>maxdepth)
return;
CMyFtpFileFind finder(pFTP);
bFlag=finder.FindFile(NULL,INTERNET_FLAG_DONT_CACHE|
INTERNET_FLAG_RESYNCHRONIZE);
while(bFlag) {
if(bQuit) {
return;
}
if(::PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE)) {
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
bFlag=finder.FindNextFile();
CString yytemp=szMainTitle;
yytemp+=finder.MyGetFileURL();
(AfxGetApp()->GetMainWnd())->SetWindowText(yytemp);
bNeedSearch=FALSE;
if(finder.IsDirectory()||
finder.MatchesMask(FILE_ATTRIBUTE_REPARSE_POINT)) {
BOOL bResult=FALSE;
if(finder.IsDirectory()) {
if(finder.IsDots()) {
bResult=TRUE;
}
}
if(bResult) {
continue;
}
if(depth<=maxdepth) {
CString xxx=finder.GetFileName();
if(dircontent==NULL) {
bNeedSearch=TRUE;
} else if(bOmit) {
xxx.MakeUpper();
if(xxx.Find(dircontent)!=-1) {
bNeedSearch=TRUE;
}
} else if(xxx.Find(dircontent)!=-1) {
bNeedSearch=TRUE;
}
if(bQuit) {
return;
}
if(bNeedSearch) {
directories++;
CString ttt=finder.GetFileName();
csDirectories.Add(ttt);
BOOL bGotIt=FALSE;
if(bOmit) {
ttt.MakeUpper();
LPSTR pStr=ttt.LockBuffer();
if(regular.Search(pStr)) {
bGotIt=TRUE;
}
ttt.UnlockBuffer();
} else {
LPSTR pStr=ttt.LockBuffer();
if(regular.Search(pStr)) {
bGotIt=TRUE;
}
ttt.UnlockBuffer();
}
if(bQuit) {
return;
}
if(bGotIt) {
CString xx=finder.MyGetFilePath();
CWftp1Dlg *pDlg=(CWftp1Dlg*)CWftp1Dlg::FromHandle(hWnd);
CTreeCtrl *pTree=(CTreeCtrl*)pDlg->GetDlgItem(IDC_TREE_FTPS);
pTree->InsertItem(xx,
*((HTREEITEM*)arAllFTPs.GetAt(index)));
pTree->Expand(*((HTREEITEM*)arAllFTPs.GetAt(index)),
TVE_EXPAND);
}
}
} else {
directories++;
CString ttt=finder.GetFileName();
csDirectories.Add(ttt);
BOOL bGotIt=FALSE;
if(bOmit) {
ttt.MakeUpper();
LPSTR pStr=ttt.LockBuffer();
if(regular.Search(pStr)) {
bGotIt=TRUE;
}
ttt.UnlockBuffer();
} else {
LPSTR pStr=ttt.LockBuffer();
if(regular.Search(pStr)) {
bGotIt=TRUE;
}
ttt.UnlockBuffer();
}
if(bQuit) {
return;
}
if(bGotIt) {
CString xx=finder.MyGetFilePath();
CWftp1Dlg *pDlg=(CWftp1Dlg*)CWftp1Dlg::FromHandle(hWnd);
CTreeCtrl *pTree=(CTreeCtrl*)pDlg->GetDlgItem(IDC_TREE_FTPS);
pTree->InsertItem(xx,
*((HTREEITEM*)arAllFTPs.GetAt(index)));
pTree->Expand(*((HTREEITEM*)arAllFTPs.GetAt(index)),
TVE_EXPAND);
}
}
} else {
if(depth<=maxdepth) {
BOOL bGotIt=FALSE;
CString ttt=finder.GetFileName();
if(bOmit) {
ttt.MakeUpper();
LPSTR pStr=ttt.LockBuffer();
if(regular.Search(pStr)) {
bGotIt=TRUE;
}
ttt.UnlockBuffer();
} else {
LPSTR pStr=ttt.LockBuffer();
if(regular.Search(pStr)) {
bGotIt=TRUE;
}
ttt.UnlockBuffer();
}
if(bQuit) {
return;
}
if(bGotIt) {
CString xx=finder.MyGetFilePath();
CWftp1Dlg *pDlg=(CWftp1Dlg*)CWftp1Dlg::FromHandle(hWnd);
CTreeCtrl *pTree=(CTreeCtrl*)pDlg->GetDlgItem(IDC_TREE_FTPS);
pTree->InsertItem(xx,
*((HTREEITEM*)arAllFTPs.GetAt(index)));
pTree->Expand(*((HTREEITEM*)arAllFTPs.GetAt(index)),
TVE_EXPAND);
}
}
}
}
finder.Close();
CString strObject;
CString temp;
int i;
if(pFTP->GetCurrentDirectory(temp)) {
for(i=0;i<directories;i++) {
="" if(bquit)="" return;
="" }
="" if(::peekmessage(&msg,null,null,null,pm_remove))="" ::translatemessage(&msg);
="" ::dispatchmessage(&msg);
="" strobject="csDirectories.GetAt(i);
" if(strobject.right(1)="=CString(".")||strObject.Find("..")!=-1)" continue;
="" int="" chindex;
="" while((chindex="strObject.Find("%"))!=-1)" cstring="" combine;
="" char="" buf[3];
="" if(chindex+1="">=strObject.GetLength())
break;
buf[0]=strObject.GetAt(chindex+1);
if(!(buf[0]>='0'&&buf[0]<='9'))
break;
if(chindex+2>=strObject.GetLength())
break;
buf[1]=strObject.GetAt(chindex+2);
if(!(buf[0]>='0'&&buf[0]<='9'))
break;
buf[2]=0;
char ch=LOBYTE(LOWORD(strtoul(buf,NULL,16)));
combine=strObject.Left(chindex)
+ch
+strObject.Right(strObject.GetLength()-chindex-3);
strObject=combine;
}
if(pFTP->SetCurrentDirectory(strObject)) {
if(bQuit) {
return;
}
IterFind(pFTP,szStrToFind,dircontent,maxdepth,bOmit,index,depth+1);
pFTP->SetCurrentDirectory(temp);
}
}
}
}
There will be about 200 threads of this function running at the same time. I have no idea at all about the reason!
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
How do you do parsing? If i wanted to write a parser to parse the input line.. how would i go about doing that with the characters @ and # ?
Thanks
kginsberg@hotmail.com
|
|
|
|
|
The simplest parser is strtok(). Pass it your input line and a string of delimiters, and it will return tokens parsed out of the input string.
--Mike--
http://home.inreach.com/mdunn/
Trillian: What are you supposed to do with a manically depressed robot?
Marvin: You think you've got problems. What are you supposed to do if you are a manically depressed robot?
|
|
|
|
|
I already post a thread on the subject but it wasn't clearly explained. So here is my new question.
I'm making a plugin based file loader. When I cam to loading zipped files, I realized I had to callback my plugin API with each contained file so as to be able to read them.
That is:
1/ The plugin engine call the unzip dll
2/ the unzip dll read each file
loop:
for each file:
3/ call back the plugin api with the file data (name is enough)
4/ the plugin API uncode the file
end of loop:
5/ end of unzip plugin
I don't know how to write this in C++. The ideal would be the 3rd step
to call a method inside the plugin API.
Can someone tell me ? This is very important... to me )
Yarp
|
|
|
|
|
There's an exmple callback in the C++ forum FAQ. Give that a look, and ask here again if you still have questions.
--Mike--
http://home.inreach.com/mdunn/
Trillian: What are you supposed to do with a manically depressed robot?
Marvin: You think you've got problems. What are you supposed to do if you are a manically depressed robot?
|
|
|
|
|
Thanks a lot, I have a look immediately
Yarp
|
|
|
|
|
Ok, everything is clear now. I understood the howto, I was stuck since 2 weeks. Thank and thanks for your articles, espcially the one about custom draw List controls.
Cheers
Yarp
|
|
|
|
|
Hi, it's me again, and for the last time reagarding this question
I just got my Browser Helper Object DLL to work correctly with the Internet Explorer.
I can handle the BeforeNavigate2 event the InternetExplorer fires.
But there's one problem that I can't get rid of, I think it is Microsoft's fault:
When I e.g. just type "foo" into the addressbar and push enter I thought that the variable VARIANT *URL in the BeforeNavigate2 event would be equal to "foo".
But since the website "foo" doesn't exist InternetExplorer redirects itself to a site like search.msn.com.
Therefore *URL is equal the link the IE redirects to.
Is there really no way to get the text the user typed into the addressbar?
thanks in advance
|
|
|
|
|
You can disable searching from the Address bar, on the Advanced tab of the IE options dialog.
--Mike--
http://home.inreach.com/mdunn/
Trillian: What are you supposed to do with a manically depressed robot?
Marvin: You think you've got problems. What are you supposed to do if you are a manically depressed robot?
|
|
|
|
|
Hi, All.
=======
Does anyone know how do text files work with unicode?
BTW: come to #CodeProject on DalNet (mIRC)
|
|
|
|
|
I want my sound in the resource.
How does the syntax look?
ID_WAVE WAVESOMETHING 1000??
Help me!!
/A lost in space man
|
|
|
|
|
Hello,
The easiest way to add it to the resource is to click on the "Resource" view tab, and then right click on the very top folder and select import. Then browse to your wave file (remember to select the *.wav extension), and then select import.
Now your wave is in the resource, I hope this helps.
|
|
|
|
|
How can I view debug information of a DLL when the DLL is called by another application?
e.g. foo.exe launches foo.dll
how can I then view debug-information about from the foo.dll?
|
|
|
|
|
Load your DLL project into Visual Studo. In the Debug Project Settings set the Executable for Debug Session to foo.exe. Hit F5. The Foo.exe will run, when it loads your foo.dll you will be able to debug the dll.
Michael
|
|
|
|
|
Thanks, it's easier than I thought
|
|
|
|
|
although it is simple
Who can explain me : What is "release mode "
|
|
|
|
|
In my mind it means all the debug informations were removed.
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
I call a DAO function,but when it returns error
code,I don't know what it means,where can i get the error code table?thanks.
|
|
|
|
|
|
I created dll file in vc++.
My client works with Delphi.
Is he need my lib file also ?
|
|
|
|
|
Even if it would need a .lib file I think Delphi couldn't read it.
I guess you don't need the .lib file, just the declarations of your functions (just like VB), but I'm not sure 'cause I never used Delphi. You may try with the .def file if it needs some.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Hi, all.
=======
I have an app (Server) that receives forms from the browser.
I want my app to support unicode characters, for example German language.
I receive characters like this %C3%B6 and other one like this %C3%B9
How should I handle it ????
the solution I have right now is a conversion table .
%C3%B6 is returned to the browser as ö
%C3%BC is returned to the browser as ü
%C3%A4 is returned to the browser as ä
if I do %B6 + %40 ==>> 182 + 64 ==>> 246 <<== the number I need to send back.
this solution works only on western europe languages.
And I must support whole the languages.
thanks.
|
|
|
|