/*-------------------------------------------------------------------------------/
  関数名:CString GetLongFileName(LPCTSTR lpShortPath)
  引 数:lpShortPath ショートファイル名が入った文字列へのポインタを指定。
  戻り値:ショートファイル名に対応したロングファイル名。(フルパス)
      ショートファイル名のファイルが見つからないときは空の文字列を返します。
  解 説:ショートファイル名からロングファイル名を取得。
/-------------------------------------------------------------------------------*/
CString GetLongFileName(LPCTSTR lpShortPath)
{
    CFileFind fnd;
    int nStart = 2;
    CString strLongPath;
    if(fnd.FindFile(lpShortPath, 0))
    {
        // ショートファイルネームのフルパスを取得
        fnd.FindNextFile();
        CString strShortPath = fnd.GetFilePath();
        fnd.Close();
        strLongPath = strShortPath.Left(2);
        // ディレクトリ名もロングファイル名変換する。
        while(nStart != -1)
        {
            strLongPath += _T("\\");
            // ディレクトリを1つずつ取り出す
            nStart = strShortPath.Find('\\', nStart + 1);
            // ディレクトリのロングファイル名を取得
            if(nStart != -1)
                fnd.FindFile(strShortPath.Left(nStart), 0);
            // 最後のファイル名のロングファイル名を取得
            else
                fnd.FindFile(strShortPath, 0);
            // ロングファイル名に変換したものを記憶していく
            fnd.FindNextFile();
            strLongPath += fnd.GetFileName();
            fnd.Close();
        }
    }
    return strLongPath;
}
       |