2012-04-24 4 views
0

한국어/일본어 Windows에서 작동하려면 다음 코드가 필요합니다. 그냥 작동하지 않는다. 이유를 말해 줄 수 없다.Windows Search C++ (MFC) CFindFiles 경로 구분 기호

5 너희들 도와 줘?

void RecurseSearch(LPCTSTR pstr, CString serchTerm, CSimpleMap<CString,CString>* arr) 
{ 
    CFileFind finder; 
    // build a string with wildcards 
    CString strWildcard; 
    int code_point = 0x5c ; 
    WCHAR chr = (WCHAR) code_point; 
    strWildcard.Format(_T("%s%c*%s*"), pstr,chr,serchTerm); 
    CString actualFolder; 
    // start working for files 
    BOOL bWorking = finder.FindFile(strWildcard); 

    while (bWorking) 
    { 

     bWorking = finder.FindNextFile(); 
     actualFolder=finder.GetFilePath(); 
     // skip . and .. files; otherwise, we'd 
     // recur infinitely! 

     if (finder.IsDots()) 
      continue; 

     // if it's a directory, recursively search it 

     else if (finder.IsDirectory()) 
     { 
      CString str = finder.GetFilePath(); 
      RecurseSearch(str, serchTerm, arr); 
     } 
     else 
     { 
      if(arr->GetSize()>200) return; 
      if(arr->FindKey(finder.GetFileURL())==-1) 
       arr->Add(finder.GetFileURL(),finder.GetFileURL()); 
     } 
    } 
    bWorking = finder.FindFile(pstr+(CString)chr+(CString)_T("*")); 
    while(bWorking) 
    { 
     bWorking = finder.FindNextFile(); 
     actualFolder =finder.GetFilePath(); 
     if (!finder.IsDirectory() || finder.IsDots()) continue; 
     else 
     { 
      RecurseSearch(actualFolder, serchTerm, arr); 
     } 

    } 
    finder.Close(); 
} 

이 코드는 미국 Windows에서 잘 작동하지만 한국어를하지 않습니다 ... 이 난 올바른 유니 코드 아무것도하지만 ...에

편집을 경로 구분 기호를 설정 : 내가 ' 오류를 식별 했으므로 ItemNames 및 ItemDisplayNames와 관련이 있습니다. ItemDisplayNames를 검색해야하지만 ItemName을 찾기 위해 CFindFile을 검색해야합니다.

ISearchFolderItemFactory를 사용하도록 코드를 변경 한 다음 AQS 쿼리를 수행합니다.

타이 녀석 어쨌든!

답변

1

경로 구분 기호에 백 슬래시를 사용하십시오. 현재 언어와 관계없이 백 슬래시는 모든 경우에 허용되는 것으로 문서화됩니다. MFC가 문제를 일으킬 수 있습니다 ...

다음은 도움이되는 두 가지 링크입니다.

http://msdn.microsoft.com/en-us/library/dd317748(v=vs.85).aspx

http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx#naming_conventions

+1

NOP! 작동하지 않습니다! 나는 이미 '/' '\\' '\' '\'트릭을하지 않는 것 같다! –

+0

@Carlos_rpg : Odd. MFC의 어떤 버전입니까? 한국어 버전에서 '₩'의 문자 값은 무엇입니까? 예 :'printf ("0x % X \ n", '₩');'- MSFT에 따르면, 경로 sep는 모든 경우 0x5C이어야하며 단지 다른 문자로 표시되어야합니다. 적어도 그것이 내가 읽는 방식이다. – JimR