Ejemplo n.º 1
0
void SlimItem::InsertPath(const CString& strPath, const CStringA& strOsFlag)
{
    CString strRealPath;
    TCHAR* temp = new TCHAR[MAX_PATH * 2];
    WinVersion sysVersion = KGetWinVersion();

    if (!strOsFlag.CompareNoCase("xp") && sysVersion >= WINVERSION_VISTA)
        return;

    if (!strOsFlag.CompareNoCase("vista") && sysVersion != WINVERSION_VISTA)
        return;

    if (!strOsFlag.CompareNoCase("win7") && sysVersion <= WINVERSION_VISTA)
        return;

    if (!ExpandEnvironmentStrings(strPath, temp, MAX_PATH * 2))
        return;

    strRealPath = temp;

    if (strRealPath.Find(L"*") != -1)
    {
        _FindPath(strRealPath);
    } 
    else if (::GetFileAttributes(strRealPath) != INVALID_FILE_ATTRIBUTES)
    {    
        m_itemPaths.Add(strRealPath);
    }
}
Ejemplo n.º 2
0
BOOL CConfigData::_CheckChangeIE(DIRECTORYWORK& dirword)
{
    BOOL bRet = FALSE;
    CGetEnvPath evnPath;
    TCHAR szBuffer[MAX_PATH] = { 0 };
    CString strPath;

    UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);

    if (uResult < 3 || szBuffer[1] != TEXT(':') || szBuffer[2] != TEXT('\\'))
    {
        goto Clear0;     
    }
    szBuffer[3] = TEXT('\0');
    strPath += szBuffer;
    memset(szBuffer, 0, sizeof(szBuffer));
    DWORD MaxSize = sizeof(szBuffer);
    GetUserName(szBuffer, &MaxSize);

    if (KGetWinVersion() >= 4) // win7
    {
        strPath += L"Users\\"; 
        strPath += szBuffer; 
        strPath += L"\\AppData\\Local\\Microsoft\\Windows\\Temporary Internet Files\\";

        if (strPath.CompareNoCase(dirword.strDirectory.at(0)) == 0)
        {
            dirword.strDirectory.clear();
            dirword.strDirectory.resize(1);
        }
    }
    else
    {
        strPath += L"Documents and Settings\\"; 
        strPath += szBuffer; 
        strPath += L"\\Local Settings\\Temporary Internet Files\\";

        if (strPath.CompareNoCase(dirword.strDirectory.at(0)) == 0)
        {
            dirword.strDirectory.clear();
            dirword.strDirectory.resize(1);
        }
    }
    bRet = TRUE;
Clear0:

    dirword.strDirectory.at(0) = strPath;

    return bRet;
}
Ejemplo n.º 3
0
void CUIHandlerSystemSlim::OnCommand(UINT uNotifyCode, int nID, CWindow wndCtl)
{
    BOOL bRet = FALSE;
    
    if (nID >= DEF_SLIM_MENU_ID_BASE && nID <= DEF_SLIM_MENU_ID_BASE_END)
    {
        SlimItem& slimItem = m_slimData.GetItem(m_nCurrentIndex);
        CAtlArray<CString> vPaths;
        int index = nID - 1000;

        slimItem.GetPaths(vPaths);

        if (slimItem.Id() == 0) //壁纸 暂时先这样写
        {
            //        ExpandEnvironmentStrings(L"%Systemroot%\\Web\\Wallpaper\\", temp, MAX_PATH * 2);
            TCHAR szLocate[MAX_PATH] = { 0 };
            _tcscpy_s(szLocate, MAX_PATH, vPaths[0]);
            if (KGetWinVersion() != WINVERSION_XP)
            {
                PathRemoveFileSpec(szLocate);   
            }
            PathRemoveFileSpec(szLocate);

            vPaths.RemoveAll();
            vPaths.Add(szLocate);
        }
        else if (slimItem.Id() == 1 || slimItem.Id() == 3 || slimItem.Id() == 2|| slimItem.Id() == 4)
        {
            CString strPath = vPaths[0];
            TCHAR szLocate[MAX_PATH] = { 0 };

            _tcscpy_s(szLocate, MAX_PATH, strPath);

            PathRemoveFileSpec(szLocate);

            vPaths.RemoveAll();
            vPaths.Add(szLocate);
        }

        slimhelper::LocateFile(vPaths[index]);
    }
    SetMsgHandled(FALSE);
}
Ejemplo n.º 4
0
void SlimItem::_GetWallpaperFilterPath(CString& strPath)
{
    TCHAR temp[MAX_PATH * 2] = {0};
    TCHAR szLongPathBuffer[MAX_PATH * 2] = { 0 };
    DWORD len = sizeof(szLongPathBuffer);
    CString strValueName;

    if (KGetWinVersion() == WINVERSION_WIN7)
    {
        strValueName = L"WallpaperSource";
    }
    else
    {
        strValueName = L"Wallpaper";
    }

    // 过滤 当前壁纸
    GetRegistryValue(HKEY_CURRENT_USER,
        L"Software\\Microsoft\\Internet Explorer\\Desktop\\General",
        strValueName,
        NULL,
        (LPBYTE)szLongPathBuffer,
        &len
        );

    if (ExpandEnvironmentStrings(szLongPathBuffer, temp, MAX_PATH * 2))
    {
        strPath = temp;
    }
    else
    {
        strPath = szLongPathBuffer;
    }

    if (strPath.IsEmpty())
    {
        strPath = L"NULL";
    }
}
Ejemplo n.º 5
0
// 获得FlashGet的下载目录
BOOL bigfilehelper::GetFlashGetDownloadDirs(std::vector<CString>& vDirs)
{
    WinVersion  winver = KGetWinVersion();
    IniEditor IniEdit;
    BOOL bRet = TRUE;
    WCHAR szAppDataPath[MAX_PATH] = { 0 };

    WCHAR szAppPath[MAX_PATH] = {0};
    szAppPath[0] = GetSystemDrive();
    wcscat(szAppPath,L":\\Downloads");
    vDirs.push_back(szAppPath);

    if(WINVERSION_WIN7 == winver)
    {
        CString tmpStrPath = L"";
        bRet = SHGetSpecialFolderPath(NULL, szAppDataPath, CSIDL_APPDATA, FALSE);
        if (!bRet)
            goto clean0;
        tmpStrPath += szAppDataPath;
        tmpStrPath += L"\\FlashGet\\v3\\dat\\Appsetting.cfg";
        IniEdit.SetFile(tmpStrPath.GetBuffer());
        std::wstring UserPath = IniEdit.ReadString(L"FlashGet3 Setting Value",L"UserPath");
        if(UserPath.length()==0)
            bRet = FALSE;
        else 
        {


            if(UserPath[0]==GetSystemDrive()||UserPath[0]==GetSystemDrive()-32||UserPath[0]==GetSystemDrive()+32)
                vDirs.push_back(UserPath.c_str());
            else bRet = FALSE;
        }
    }
    else
    {
        TCHAR szLongPathBuffer[MAX_PATH] = { 0 };
        DWORD len = sizeof(szLongPathBuffer);
        GetRegistryValue(HKEY_LOCAL_MACHINE,
            L"SOFTWARE\\FlashGet Network\\FlashGet 3",
            L"Path",
            NULL,
            (LPBYTE)szLongPathBuffer,
            &len
            );
        if(wcslen(szLongPathBuffer) == 0)
            bRet = FALSE;
        else 
        {
            ::PathAppend(szLongPathBuffer,L"dat\\Appsetting.cfg");
            IniEdit.SetFile(szLongPathBuffer);
            std::wstring UserPath = IniEdit.ReadString(L"FlashGet3 Setting Value",L"UserPath");
            if(UserPath.length()==0)
                bRet = FALSE;
            else 
            {
                if(UserPath.at(0)==GetSystemDrive()||UserPath[0]==GetSystemDrive()-32||UserPath[0]==GetSystemDrive()+32)
                    vDirs.push_back(UserPath.c_str());
                else bRet = FALSE;
            }

        }
    }
clean0:
    return bRet;
}
Ejemplo n.º 6
0
// 获得Firefox的下载目录
BOOL bigfilehelper::GetFirefoxDownloadDirs(std::vector<CString>& vDirs)
{
    WCHAR szPath[MAX_PATH] = {0};
    BOOL bRet = FALSE;
    CString szPathFull;
    CString szPathFullEx;
    CString szTarget;
    CString strPath = L"";
    int nPos = -1;
    WCHAR szAppDataPath[MAX_PATH] = { 0 };
    WinVersion winVer;

    winVer = KGetWinVersion();

    if(WINVERSION_WIN7 == winVer)
    {
        bRet = SHGetSpecialFolderPath(NULL, szAppDataPath, CSIDL_PERSONAL, FALSE);
        if(bRet)
        {
            CString tmpdir(szAppDataPath);
            tmpdir = tmpdir.Left(tmpdir.ReverseFind(L'\\'));
            tmpdir += L"\\downloads";
            if(tmpdir.GetAt(0)==GetSystemDrive())
                vDirs.push_back(tmpdir);
        }

    }
    else
    {
        bRet = SHGetSpecialFolderPath(NULL, szAppDataPath, CSIDL_PERSONAL, FALSE);
        if(bRet)
        {
            wcscat(szAppDataPath,L"\\下载");
            if(szAppDataPath[0]==GetSystemDrive())
                vDirs.push_back(szAppDataPath);
        }
    }

    bRet = SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA, FALSE);
    szPathFull = szPath;
    szPathFullEx = szPath;
    szPathFullEx += _T("\\Mozilla\\Firefox");
    szPathFull += _T("\\Mozilla\\Firefox\\profiles.ini");

    WCHAR szRecord[MAX_PATH] = {0};
    std::vector<std::wstring> vLogCache;
    std::vector<std::wstring>::iterator itor;

    GetPrivateProfileString(L"Profile0", L"Path", NULL, szRecord, MAX_PATH - 1, szPathFull);

    szPathFullEx += L"\\";
    szPathFullEx += szRecord;

    szPathFullEx += L"\\prefs.js";

    const WCHAR* Point = NULL;
    HRESULT hrRet = E_FAIL;
    std::vector<std::wstring> vcStrline;
    BYTE* pBuf = NULL;
    FILE* pFile = NULL;
    DWORD dwRealReadSize = 0;

    DWORD dwFileSize  = _DoGetFileSizeByFileName(szPathFullEx);
    if (dwFileSize <= 0)
    {
        hrRet = E_FAIL;
        goto _Exit;
    }

    pBuf = new BYTE[dwFileSize * 2 + 2];
    if (!pBuf)
    {
        hrRet = E_OUTOFMEMORY;
        goto _Exit;
    }

    ::ZeroMemory(pBuf, dwFileSize * 2 + 2);

    pFile = ::_wfopen(szPathFullEx, L"rt,ccs=UTF-8");
    if (!pFile)
    {
        hrRet = E_FAIL;
        goto _Exit;
    }

    dwRealReadSize = (DWORD)::fread(pBuf, sizeof(WCHAR), dwFileSize, pFile);
    if (dwRealReadSize == 0)
    {
        hrRet = E_FAIL;
        goto _Exit;
    }

    WCHAR* pszInfo = (WCHAR*)pBuf;

    DWORD dwLineCount = _DoGetLineByBuf(pszInfo, (DWORD)::wcslen(pszInfo), vLogCache);

    for (itor = vLogCache.begin(); itor != vLogCache.end(); itor++)
    {
        szTarget = (*itor).c_str();
        nPos = szTarget.Find(L"browser.download.dir");
        if (nPos != -1)
        {
            nPos = szTarget.Find(L",");
            szTarget = szTarget.Right(szTarget.GetLength() - nPos - 3);
            nPos = szTarget.Find(L"\"");
            szTarget = szTarget.Left(nPos);
            break;
        }
    }
    if (_wcsicmp(szTarget, L"") == 0)
    {
        return FALSE;
    }

    for (int nIndex=0; nIndex<szTarget.GetLength();)
    {
        if(szTarget.GetAt(nIndex)==L'\\'&&szTarget.GetAt(nIndex+1)==L'\\')
        {
            strPath += L"\\";
            nIndex += 2;
        }
        else
        {
            strPath += szTarget.GetAt(nIndex);
            nIndex++;
        }

    }
    if(strPath.GetAt(0)==GetSystemDrive()||strPath[0]==GetSystemDrive()-32||strPath[0]==GetSystemDrive()+32)
        vDirs.push_back(strPath);
    else goto _Exit;
    hrRet = S_OK;

_Exit:

    if (pBuf)
    {
        delete []pBuf;
        pBuf = NULL;
    }
    if (pFile)
    {
        fclose(pFile);
        pFile = NULL;
    }
    return TRUE;
}
Ejemplo n.º 7
0
BOOL SlimData::LoadDataSync()
{
    BOOL retval = FALSE;
    KAutoLock lock(m_lock);
    CStringA  strXml;
    TCHAR szModule[MAX_PATH] = { 0 };
    TiXmlDocument xmlDoc;
    TiXmlElement* pXmlSlims = NULL;
    TiXmlElement* pXmlItem = NULL;
    CDataFileLoader datloader;
    
    GetModuleFileName(NULL, szModule, MAX_PATH);
    PathRemoveFileSpec(szModule);
    PathAppend(szModule, _T("data\\slimdata.dat"));

    if (!datloader.LoadFile(szModule, strXml))
        goto clean0;

    xmlDoc.Parse(strXml);

    pXmlSlims = xmlDoc.FirstChildElement("slims");
    if (!pXmlSlims)
        goto clean0;

    pXmlItem = pXmlSlims->FirstChildElement("slim");
    while (pXmlItem)
    {
        TiXmlElement* pXmlId = pXmlItem->FirstChildElement("id");
        TiXmlElement* pXmlName = pXmlItem->FirstChildElement("name");
        TiXmlElement* pXmlDescription = pXmlItem->FirstChildElement("description");
        TiXmlElement* pXmlWarning = pXmlItem->FirstChildElement("warning");
        TiXmlElement* pXmlMethod = pXmlItem->FirstChildElement("method");

        if (pXmlId && pXmlName && pXmlDescription && pXmlWarning && pXmlMethod)
        {
            SlimItem item;
            TiXmlElement* pXmlPath = NULL;

            item.SetLock(m_sharedLock);
            item.SetId(::StrToIntA(pXmlId->GetText()));
            item.SetName(KUTF8_To_UTF16(pXmlName->GetText()));
            item.SetDescription(KUTF8_To_UTF16(pXmlDescription->GetText()));
            item.SetWarning(KUTF8_To_UTF16(pXmlWarning->GetText()));
            if (!stricmp(pXmlMethod->GetText(), "delete"))
            {
                item.SetMethod(SLIM_DELETE_FILE);
            }
            else if (!stricmp(pXmlMethod->GetText(), "compress"))
            {
                item.SetMethod(SLIM_COMPRESS_FILE);
            }

            pXmlPath = pXmlItem->FirstChildElement("path");
            while (pXmlPath)
            {
                CStringA strOsFlag = pXmlPath->Attribute("os");
                item.InsertPath(KUTF8_To_UTF16(pXmlPath->GetText()), strOsFlag);
                pXmlPath = pXmlPath->NextSiblingElement("path");
            }

            if (item.Valid() || (KGetWinVersion() < WINVERSION_VISTA && item.Id() == 10))
            {
                m_slimItems.Add(item);
            }
        }

        pXmlItem = pXmlItem->NextSiblingElement("slim");
    }

    retval = TRUE;

clean0:
    if (m_hNotifyWnd)
    {
        ::PostMessage(m_hNotifyWnd, SLIM_WM_LOADCOMPLETE, 0, 0);
    }

    return retval;
}
Ejemplo n.º 8
0
LRESULT CUIHandlerSystemSlim::OnItemLink(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    int nItem = (int)wParam;
    CAtlArray<CString> vPaths;
    CString strPath;    

    if (nItem < 0 || nItem >= m_slimData.GetCount())
        goto Clear0;

    SlimItem& item = m_slimData.GetItem(nItem);

    m_nCurrentIndex = nItem;

    item.GetPaths(vPaths);

    if (vPaths.GetCount() <= 0)
        goto Clear0;

    if (item.Id() == 0) //壁纸 暂时先这样写
    {
//        ExpandEnvironmentStrings(L"%Systemroot%\\Web\\Wallpaper\\", temp, MAX_PATH * 2);
        TCHAR szLocate[MAX_PATH * 2] = { 0 };
        _tcscpy_s(szLocate, MAX_PATH * 2, vPaths[0]);
        if (KGetWinVersion() == WINVERSION_WIN7)
        {
            PathRemoveFileSpec(szLocate);   
        }
        PathRemoveFileSpec(szLocate);

        vPaths.RemoveAll();
        vPaths.Add(szLocate);
    }
    else if (item.Id() == 1 || item.Id() == 3 || item.Id() == 2 || item.Id() == 4)
    {
        CString strPath = vPaths[0];
        TCHAR szLocate[MAX_PATH * 2] = { 0 };

        _tcscpy_s(szLocate, MAX_PATH * 2, strPath);

        PathRemoveFileSpec(szLocate);

        vPaths.RemoveAll();
        vPaths.Add(szLocate);
    }

    if (vPaths.GetCount() > 0)
    {
        // 弹出目录框
        HMENU hMenu = NULL;
        CPoint pos;

        hMenu = _InitFileContextMenu(vPaths);
        if (!hMenu)
            goto Clear0;

        GetCursorPos(&pos);
        ::TrackPopupMenu(
            hMenu,
            TPM_LEFTALIGN | TPM_RIGHTBUTTON, 
            pos.x, 
            pos.y,
            0,
            m_dlg->m_hWnd,
            NULL
            );

    }
Clear0:
    return 0L;
}
Ejemplo n.º 9
0
BOOL slimhelper::ScanDirectory(const CString& strDirectory,
                               ISystemSlimCallBack* piCallback)
{
    BOOL retval = FALSE;
    CString strPath;
    CString strFind;
    HANDLE hFind = INVALID_HANDLE_VALUE;
    WIN32_FIND_DATA findData;
    BOOL bRetCode;
    BOOL bContinue;

    if (strDirectory.IsEmpty() || !piCallback)
        goto clean0;

    strPath = strDirectory;
    if (strPath[strPath.GetLength() - 1] != _T('\\'))
        strPath += _T("\\");

    strFind = strPath + _T("*.*");

    hFind = ::FindFirstFile(strFind, &findData); 
    if (INVALID_HANDLE_VALUE == hFind)
    {
        retval = TRUE;
        goto clean0;
    }

    bRetCode = TRUE;
    while (bRetCode)
    {
        if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)  
        {
            if (_tcscmp(findData.cFileName, _T(".")) &&
                _tcscmp(findData.cFileName, _T("..")))
            {
                CString strSubDir = strPath + findData.cFileName;
                strSubDir += _T("\\");
                if (!ScanDirectory(strSubDir, piCallback))
                    goto clean0;
            }
        }
        else
        {
            CString strFullFilePath = strPath + findData.cFileName;
            ULONGLONG qwFileSize = ((ULONGLONG)findData.nFileSizeHigh << 32) + findData.nFileSizeLow;
            
            if (KGetWinVersion() <= WINVERSION_SERVER_2003)
            {
                if (!::SfcIsFileProtected(NULL, strFullFilePath))
                    ScanFile(strFullFilePath, qwFileSize, findData.dwFileAttributes, piCallback);
            }
            else
            {
                ScanFile(strFullFilePath, qwFileSize, findData.dwFileAttributes, piCallback);
            }

            bContinue = piCallback->OnIdle();
            if (!bContinue)
                goto clean0;
        }

        bRetCode = ::FindNextFile(hFind, &findData);
    }

    retval = TRUE;

clean0:
    if (hFind != INVALID_HANDLE_VALUE)
    {
        FindClose(hFind);
        hFind = INVALID_HANDLE_VALUE;
    }

    return retval;
}
Ejemplo n.º 10
0
BOOL slimhelper::DeleteDirectory(const CString& strDirectory,
                                 ISystemSlimCallBack* piCallback,
                                 BOOL bKeepRootDir,
                                 int nLevel) 
{
    BOOL retval = FALSE;
    CString strPath;
    CString strFind;
    HANDLE hFind = INVALID_HANDLE_VALUE;
    WIN32_FIND_DATA findData;
    BOOL bRetCode;
    BOOL bContinue;

    if (strDirectory.IsEmpty() || !piCallback)
        goto clean0;

    strPath = strDirectory;
    if (strPath[strPath.GetLength() - 1] != _T('\\'))
        strPath += _T("\\");

    strFind = strPath + _T("*.*");

    hFind = ::FindFirstFile(strFind, &findData); 
    if (INVALID_HANDLE_VALUE == hFind)
    {
        retval = TRUE;
        goto clean0;
    }

    bRetCode = TRUE;
    while (bRetCode)
    {
        if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)  
        {
            if (_tcscmp(findData.cFileName, _T(".")) &&
                _tcscmp(findData.cFileName, _T("..")))
            {
                CString strSubDir = strPath + findData.cFileName;
                strSubDir += _T("\\");
                if (!DeleteDirectory(strSubDir, piCallback, bKeepRootDir, nLevel + 1))
                    goto clean0;
            }
        }
        else
        {
            CString strFullFilePath = strPath + findData.cFileName;
            ULONGLONG qwFileSize = ((ULONGLONG)findData.nFileSizeHigh << 32) + findData.nFileSizeLow;
            
            if (KGetWinVersion() <= WINVERSION_SERVER_2003)
            {
                if (!::SfcIsFileProtected(NULL, strFullFilePath))
                    DeleteFile(strFullFilePath, qwFileSize, findData.dwFileAttributes, piCallback);
            }
            else
            {
                DeleteFile(strFullFilePath, qwFileSize, findData.dwFileAttributes, piCallback);
            }

            bContinue = piCallback->OnIdle();
            if (!bContinue)
                goto clean0;
        }

        bRetCode = ::FindNextFile(hFind, &findData);
    }

    retval = TRUE;

clean0:
    if (hFind != INVALID_HANDLE_VALUE)
    {
        ::FindClose(hFind);
        hFind = INVALID_HANDLE_VALUE;
    }
    // 尝试删除空目录,但不删除最顶上的目录
    if (nLevel != 0 || (nLevel == 0 && bKeepRootDir == FALSE))
    {
        BOOL bRemove = RemoveDirectory(strPath);
//        ATLASSERT(bRemove);
    }
//     else
//     {
//         // 创建瘦身后的标记文件
//         CString strFlag = strPath + g_kSlimFlag;
//         CAtlFile file;
//         file.Create(strFlag, 
//             FILE_GENERIC_WRITE, 
//             FILE_SHARE_READ|FILE_SHARE_WRITE,
//             CREATE_ALWAYS);
//     }
    return retval;
}
Ejemplo n.º 11
0
CString CGetEnvPath::GetEnvVariable(LPCTSTR pszName)
{
    CString strResult;
	WCHAR wcsTemp[MAX_PATH] = {0}; 
    
    TCHAR szBuffer[MAX_PATH] = { 0 };
    TCHAR szLongPathBuffer[MAX_PATH] = { 0 };

    if ( CString("systemdrive").CompareNoCase(pszName) == 0 )
    {
        //UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);
        //strResult = GetDrive(_T(""));
        UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);

        if (uResult > 3 && szBuffer[1] == TEXT(':') && szBuffer[2] == TEXT('\\'))
        {
            szBuffer[2] = TEXT('\0');
            strResult = szBuffer;
            goto Exit0;         
        }
    }
    else if ( CString("program").CompareNoCase(pszName) == 0 )
    {
        //UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);
        //strResult = GetDrive(_T(""));
        UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);

        if (uResult > 3 && szBuffer[1] == TEXT(':') && szBuffer[2] == TEXT('\\'))
        {
            szBuffer[3] = TEXT('\0');
            strResult = szBuffer;
            strResult += L"program files";
            goto Exit0;         
        }
    }
    else if ( CString("boot").CompareNoCase(pszName) == 0 )
    {
        //UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);
        //strResult = GetDrive(_T(""));
        UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);

        if (uResult > 3 && szBuffer[1] == TEXT(':') && szBuffer[2] == TEXT('\\'))
        {
            szBuffer[3] = TEXT('\0');
            strResult = szBuffer;
            strResult += L"boot";
            goto Exit0;         
        }
    }
    else if ( CString("recovery").CompareNoCase(pszName) == 0 )
    {
        //UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);
        //strResult = GetDrive(_T(""));
        UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);

        if (uResult > 3 && szBuffer[1] == TEXT(':') && szBuffer[2] == TEXT('\\'))
        {
            szBuffer[3] = TEXT('\0');
            strResult = szBuffer;
            strResult += L"recovery";
            goto Exit0;         
        }
    }
    else if ( CString("systemroot").CompareNoCase(pszName) == 0 )
    {
       
        UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);

        if (uResult > 0)
        {
            strResult = szBuffer;
            goto Exit0;         
        }
    }
    else if(CString("windir").CompareNoCase(pszName) == 0)
    {
        UINT uResult = GetWindowsDirectory(szBuffer, MAX_PATH);

        if(szBuffer[wcslen(szBuffer)-1] == _T('\\'))
            szBuffer[wcslen(szBuffer)-1] = _T('\0');

        strResult = szBuffer;
        goto Exit0;
    }
    else if ( CString("systemrecycled").CompareNoCase(pszName) == 0 )
    {
        SYSTEM_VERSION     m_eSysVer;
        KAEGetSystemVersion(&m_eSysVer);
        CString StrSuffix;
        if(m_eSysVer == enumSystem_Win_7)
        {
            StrSuffix = _T("\\$RECYCLE.BIN");
        }
        else
            StrSuffix = _T("\\Recycled");
        strResult = GetDrive(StrSuffix);

        goto Exit0;
    }
	else if ( CString("minidump").CompareNoCase(pszName) == 0 )
	{
		DWORD len = sizeof(szLongPathBuffer);
		GetRegistryValue(HKEY_LOCAL_MACHINE,
			L"SYSTEM\\CurrentControlSet\\Control\\CrashControl",
			L"MinidumpDir",
			NULL,
			(LPBYTE)szLongPathBuffer,
			&len
			);
		if(wcslen(szLongPathBuffer) == 0)
			strResult = L"%minidump%";
		else
		{
			int nFirstPos  = 0; 
			int nSecondPos = 0;
			BOOL bFind = FALSE;
			bFind = FindEnvironmentPos(szLongPathBuffer, nFirstPos, nSecondPos);
			if(bFind)
			{
				CString strLeft       ;
				CString strRight      ;
				CString strEnvName    ;
				CString strEnvVariable;
				
				strResult = szLongPathBuffer;
				strLeft    = strResult.Left(nFirstPos);
				strRight   = strResult.Mid (nSecondPos + 1);
				strEnvName = strResult.Mid(nFirstPos + 1, nSecondPos - nFirstPos - 1);
				TCHAR szTempBuf[MAX_PATH];
				DWORD dwResult = GetEnvironmentVariable(strEnvName.GetBuffer(), szTempBuf, MAX_PATH);
				if (dwResult > 0)
					strEnvVariable = szTempBuf;

				strResult = CombinationPath(strLeft, strEnvVariable, strRight);

			}
			else
				strResult = szLongPathBuffer;

			goto Exit0;

		}
	}
	else if ( CString("memdump").CompareNoCase(pszName) == 0 )
	{
		DWORD len = sizeof(szLongPathBuffer);
		GetRegistryValue(HKEY_LOCAL_MACHINE,
			L"SYSTEM\\CurrentControlSet\\Control\\CrashControl",
			L"DumpFile",
			NULL,
			(LPBYTE)szLongPathBuffer,
			&len
			);
		if(wcslen(szLongPathBuffer) == 0)
			strResult = L"%memdump%";
		else
		{
			int nFirstPos  = 0; 
			int nSecondPos = 0;
			BOOL bFind = FALSE;
			bFind = FindEnvironmentPos(szLongPathBuffer, nFirstPos, nSecondPos);
			if(bFind)
			{
				CString strLeft       ;
				CString strRight      ;
				CString strEnvName    ;
				CString strEnvVariable;

				strResult = szLongPathBuffer;
				strLeft    = strResult.Left(nFirstPos);
				strRight   = strResult.Mid (nSecondPos + 1);
				strEnvName = strResult.Mid(nFirstPos + 1, nSecondPos - nFirstPos - 1);
				TCHAR szTempBuf[MAX_PATH];
				DWORD dwResult = GetEnvironmentVariable(strEnvName.GetBuffer(), szTempBuf, MAX_PATH);
				if (dwResult > 0)
					strEnvVariable = szTempBuf;

				strResult = CombinationPath(strLeft, strEnvVariable, L"");
				strResult += strRight;
			}
			else
				strResult = szLongPathBuffer;
			if (GetFileAttributes(strResult.GetBuffer()) != FILE_ATTRIBUTE_DIRECTORY)
			{
				WCHAR szTempBuffer[MAX_PATH] = {0};
				wcscpy_s(szTempBuffer, MAX_PATH - 1, strResult.GetBuffer());
				::PathRemoveFileSpec(szTempBuffer);
				strResult = szTempBuffer;
			}

			goto Exit0;

		}
	}
	else if (CString("archivefiles").CompareNoCase(pszName) == 0)
	{
		DWORD len = sizeof(szLongPathBuffer);
		GetRegistryValue(HKEY_LOCAL_MACHINE,
			L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VolumeCaches\\Windows Error Reporting Archive Files",
			L"Folder",
			NULL,
			(LPBYTE)szLongPathBuffer,
			&len
			);
		if (wcslen(szLongPathBuffer) == 0)
		{
			strResult = L"%archivefiles%";
		}
		else
		{
			int nFirstPos  = 0; 
			int nSecondPos = 0;
			BOOL bFind = FALSE;
			bFind = FindEnvironmentPos(szLongPathBuffer, nFirstPos, nSecondPos);
			if(bFind)
			{
				CString strLeft       ;
				CString strRight      ;
				CString strEnvName    ;
				CString strEnvVariable;

				strResult = szLongPathBuffer;
				strLeft    = strResult.Left(nFirstPos);
				strRight   = strResult.Mid (nSecondPos + 1);
				strEnvName = strResult.Mid(nFirstPos + 1, nSecondPos - nFirstPos - 1);
				TCHAR szTempBuf[MAX_PATH];
				DWORD dwResult = GetEnvironmentVariable(strEnvName.GetBuffer(), szTempBuf, MAX_PATH);
				if (dwResult > 0)
					strEnvVariable = szTempBuf;

				strResult = CombinationPath(strLeft, strEnvVariable, L"");
				strResult += strRight;
			}
			else
			{
				strResult = szLongPathBuffer;
			}
			goto Exit0;

		}
	}
	else if (CString("queuefiles").CompareNoCase(pszName) == 0)
	{
		DWORD len = sizeof(szLongPathBuffer);
		GetRegistryValue(HKEY_LOCAL_MACHINE,
			L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VolumeCaches\\Windows Error Reporting Queue Files",
			L"Folder",
			NULL,
			(LPBYTE)szLongPathBuffer,
			&len
			);
		if (wcslen(szLongPathBuffer) == 0)
		{
			strResult = L"%queuefiles%";
		}
		else
		{
			int nFirstPos  = 0; 
			int nSecondPos = 0;
			BOOL bFind = FALSE;
			bFind = FindEnvironmentPos(szLongPathBuffer, nFirstPos, nSecondPos);
			if(bFind)
			{
				CString strLeft       ;
				CString strRight      ;
				CString strEnvName    ;
				CString strEnvVariable;

				strResult = szLongPathBuffer;
				strLeft    = strResult.Left(nFirstPos);
				strRight   = strResult.Mid (nSecondPos + 1);
				strEnvName = strResult.Mid(nFirstPos + 1, nSecondPos - nFirstPos - 1);
				TCHAR szTempBuf[MAX_PATH];
				DWORD dwResult = GetEnvironmentVariable(strEnvName.GetBuffer(), szTempBuf, MAX_PATH);
				if (dwResult > 0)
					strEnvVariable = szTempBuf;

				strResult = CombinationPath(strLeft, strEnvVariable, L"");
				strResult += strRight;
			}
			else
			{
				strResult = szLongPathBuffer;
			}
			goto Exit0;

		}
	}
	else if (CString("systemarchivefiles").CompareNoCase(pszName) == 0)
	{
		DWORD len = sizeof(szLongPathBuffer);
		GetRegistryValue(HKEY_LOCAL_MACHINE,
			L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VolumeCaches\\Windows Error Reporting System Archive Files",
			L"Folder",
			NULL,
			(LPBYTE)szLongPathBuffer,
			&len
			);
		if (wcslen(szLongPathBuffer) == 0)
		{
			strResult = L"%systemarchivefiles%";
		}
		else
		{
			int nFirstPos  = 0; 
			int nSecondPos = 0;
			BOOL bFind = FALSE;
			bFind = FindEnvironmentPos(szLongPathBuffer, nFirstPos, nSecondPos);
			if(bFind)
			{
				CString strLeft       ;
				CString strRight      ;
				CString strEnvName    ;
				CString strEnvVariable;

				strResult = szLongPathBuffer;
				strLeft    = strResult.Left(nFirstPos);
				strRight   = strResult.Mid (nSecondPos + 1);
				strEnvName = strResult.Mid(nFirstPos + 1, nSecondPos - nFirstPos - 1);
				TCHAR szTempBuf[MAX_PATH];
				DWORD dwResult = GetEnvironmentVariable(strEnvName.GetBuffer(), szTempBuf, MAX_PATH);
				if (dwResult > 0)
					strEnvVariable = szTempBuf;

				strResult = CombinationPath(strLeft, strEnvVariable, L"");
				strResult += strRight;
			}
			else
			{
				strResult = szLongPathBuffer;
			}
			goto Exit0;

		}
	}
	else if (CString("systemqueuefiles").CompareNoCase(pszName) == 0)
	{
		DWORD len = sizeof(szLongPathBuffer);
		GetRegistryValue(HKEY_LOCAL_MACHINE,
			L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VolumeCaches\\Windows Error Reporting System Queue Files",
			L"Folder",
			NULL,
			(LPBYTE)szLongPathBuffer,
			&len
			);
		if (wcslen(szLongPathBuffer) == 0)
		{
			strResult = L"%systemqueuefiles%";
		}
		else
		{
			int nFirstPos  = 0; 
			int nSecondPos = 0;
			BOOL bFind = FALSE;
			bFind = FindEnvironmentPos(szLongPathBuffer, nFirstPos, nSecondPos);
			if(bFind)
			{
				CString strLeft       ;
				CString strRight      ;
				CString strEnvName    ;
				CString strEnvVariable;

				strResult = szLongPathBuffer;
				strLeft    = strResult.Left(nFirstPos);
				strRight   = strResult.Mid (nSecondPos + 1);
				strEnvName = strResult.Mid(nFirstPos + 1, nSecondPos - nFirstPos - 1);
				TCHAR szTempBuf[MAX_PATH];
				DWORD dwResult = GetEnvironmentVariable(strEnvName.GetBuffer(), szTempBuf, MAX_PATH);
				if (dwResult > 0)
					strEnvVariable = szTempBuf;

				strResult = CombinationPath(strLeft, strEnvVariable, L"");
				strResult += strRight;
			}
			else
			{
				strResult = szLongPathBuffer;
			}
			goto Exit0;

		}
	}
    else if ( CString("tudou").CompareNoCase(pszName) == 0 )
    {
         DWORD len = sizeof(szLongPathBuffer);
         GetRegistryValue(HKEY_LOCAL_MACHINE,
             L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\飞速土豆",
             L"UninstallString",
             NULL,
             (LPBYTE)szLongPathBuffer,
             &len
             );
         if(wcslen(szLongPathBuffer) == 0)
            strResult = L"%tudou%";
         else
         {
             ::PathRemoveFileSpec(szLongPathBuffer);
             ::PathAppend(szLongPathBuffer,L"tudouva.ini");
             IniEditor IniEdit;
             IniEdit.SetFile(szLongPathBuffer);
             std::wstring tmpPath = IniEdit.ReadString(L"public",L"savedirectory");
             if(tmpPath.length() <= 3)
                 strResult = L"%tudou%";
             else 
                 strResult = tmpPath.c_str();

         }

        goto Exit0;
    }else if ( CString("qvod").CompareNoCase(pszName) == 0 )
    {
        DWORD len = sizeof(szBuffer);
        GetRegistryValue(HKEY_LOCAL_MACHINE,
            L"SOFTWARE\\QvodPlayer\\Insert",
            L"Insertpath",
            NULL,
            (LPBYTE)szLongPathBuffer,
            &len
            );
        if(wcslen(szLongPathBuffer) == 0)
            strResult = L"%qvod%";
        else
        {
            //::PathRemoveFileSpec(szLongPathBuffer);
            ::PathAppend(szLongPathBuffer,L"QvodPlayer.xml");
            TiXmlDocument xmlDoc;
            const TiXmlElement *pXmlQvodPlayer = NULL;
            const TiXmlElement *pXmlGeneral = NULL;
            strResult = L"%qvod%";
            if (!xmlDoc.LoadFile(UnicodeToAnsi(szLongPathBuffer).c_str(), TIXML_ENCODING_UTF8))
                goto Exit0;
            pXmlQvodPlayer = xmlDoc.FirstChildElement("QvodPlayer");
            if (!pXmlQvodPlayer)
                goto Exit0;
            pXmlGeneral = pXmlQvodPlayer->FirstChildElement("General");
            if (pXmlGeneral)
            {
                const char* szTmp = pXmlGeneral->Attribute("Defaultsavepath");
                if(!szTmp)
                    strResult = L"%qvod%";
                else 
                    strResult = Utf8ToUnicode(szTmp).c_str();
            }

        }

        goto Exit0;
    }
    else if ( CString("xunleikankan").CompareNoCase(pszName) == 0 )
    {
        DWORD len = sizeof(szBuffer);
        GetRegistryValue(HKEY_LOCAL_MACHINE,
            L"SOFTWARE\\Thunder network\\Xmp",
            L"storepath",
            NULL,
            (LPBYTE)szBuffer,
            &len
            );
        if(wcslen(szBuffer) == 0)
            strResult = L"%xunleikankan%";
        else
        {
//            wcscat(szBuffer,L"\\VODCache");
            strResult =szBuffer;
        }

        goto Exit0;
    }
    else if ( CString("youku").CompareNoCase(pszName) == 0 )
    {
        DWORD len = sizeof(szBuffer);
        GetRegistryValue(HKEY_CURRENT_USER,
            L"SOFTWARE\\youku\\iKuAcc",
            L"CachePath",
            NULL,
            (LPBYTE)szBuffer,
            &len
            );
        if(wcslen(szBuffer) == 0)
            strResult = L"%youku%";
        else
        {
            strResult =szBuffer;
            if(strResult.Find(L"\\Desktop")!=-1)
                strResult = L"%youku%";
        }

        goto Exit0;
    }
    else if ( CString("ku6").CompareNoCase(pszName) == 0 )
    {
        DWORD len = sizeof(szLongPathBuffer);
        GetRegistryValue(HKEY_LOCAL_MACHINE,
            L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Ku6SpeedUpper",
            L"UninstallString",
            NULL,
            (LPBYTE)szLongPathBuffer,
            &len
            );
        if(wcslen(szLongPathBuffer) == 0)
        {
            CString StrSuffix = _T("\\kvideo_cache");;
            strResult = GetDrive(StrSuffix);
        }
        else
        {
            ::PathRemoveFileSpec(szLongPathBuffer);
            ::PathAppend(szLongPathBuffer,L"Ku6SpeedUpper.ini");
            IniEditor IniEdit;
            IniEdit.SetFile(szLongPathBuffer);
            std::wstring tmpPath = IniEdit.ReadString(L"Settings",L"BufPath");
            if(tmpPath.length() > 0)
                strResult = tmpPath.c_str();
            else
            {
                CString StrSuffix = _T("\\kvideo_cache");;
                strResult = GetDrive(StrSuffix);
                
            }
        }
        goto Exit0;
    }
    else if ( CString("ppstream").CompareNoCase(pszName) == 0 )
    {
        CString strTmp = GetFolderPath(L"CSIDL_APPDATA");
        strTmp += L"\\ppstream\\psnetwork.ini";
        if(!::PathFileExists(strTmp.GetBuffer()))
        {
            strTmp = L"";
            GetWindowsDirectory(szLongPathBuffer,MAX_PATH);
            strTmp = szLongPathBuffer;
            strTmp +=  L"\\psnetwork.ini";
        }
        IniEditor IniEdit;
        IniEdit.SetFile(strTmp.GetBuffer());
        std::wstring tmpPath = IniEdit.ReadString(L"vodnet",L"pgfpath");
        if(tmpPath.length()>0)
          ::PathRemoveFileSpec((LPWSTR)tmpPath.c_str());
        else
        {
            tmpPath = IniEdit.ReadString(L"vodnet",L"pgfpath1");
            if(tmpPath.length()>0)
                tmpPath.erase(tmpPath.length()-1);
        }
        strResult = tmpPath.c_str();
        goto Exit0;
    }
    else if ( CString("pptv").CompareNoCase(pszName) == 0 )
    {
        CString strTmp = GetFolderPath(L"CSIDL_COMMON_APPDATA");
        strTmp += L"\\PPLive\\Core\\config.ini";
        IniEditor IniEdit;
        IniEdit.SetFile(strTmp.GetBuffer());
        std::wstring tmpPath = IniEdit.ReadString(L"peer",L"cachepath");
        std::string utf8str = KUTF16_To_ANSI(tmpPath.c_str());
        tmpPath = Utf8ToUnicode(utf8str.c_str());
        if(tmpPath.length() == 0)
            strResult = L"%pptv%";
        else
            strResult = tmpPath.c_str();
        goto Exit0;
    }
    else if ( CString("fengxing").CompareNoCase(pszName) == 0 )
    {
        CString strTmp = GetFolderPath(L"CSIDL_PERSONAL");
        int a = strTmp.ReverseFind(L'\\');
        strTmp = strTmp.Mid(0,strTmp.ReverseFind(L'\\'));
        strTmp += L"\\funshion.ini";
        IniEditor IniEdit;
        IniEdit.SetFile(strTmp.GetBuffer());
        std::wstring tmpPath = IniEdit.ReadString(L"FILE_PATH",L"MEDIA_PATH");
        if(tmpPath.length() == 0)
            strResult = L"%fengxing%";
        else
            strResult = tmpPath.c_str();
        goto Exit0;
    }
    else if ( CString("qqlive").CompareNoCase(pszName) == 0 )
    {
       CString strTmp = GetFolderPath(L"CSIDL_APPDATA");
       strTmp += L"\\Tencent\\QQLive\\user.ini";
       IniEditor IniEdit;
       IniEdit.SetFile(strTmp.GetBuffer());
       std::wstring tmpPath = IniEdit.ReadString(L"Cache",L"Directory");
       if(tmpPath.length()>0)
       {
           tmpPath.erase(tmpPath.length()-1);
           strResult = tmpPath.c_str();
       }
       else strResult = L"%qqlive%";
       
       goto Exit0;
    }
	else if ( CString("firefox").CompareNoCase(pszName) == 0 )
	{
		WCHAR szPath[MAX_PATH] = {0};
		SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA, FALSE);
		std::wstring strPath;
		std::wstring strTemp;
		strPath = szPath;
		HANDLE hFile = INVALID_HANDLE_VALUE;
		if (strPath.rfind(L'\\') != strPath.size())
		{
			strPath += L"\\";
		}
		strPath += L"Mozilla\\Firefox\\profiles.ini";
		IniEditor inif;
		inif.SetFile(strPath.c_str());
		strTemp = inif.ReadString(L"Profile0", L"Path");
		if(strTemp.find(L"//") != -1)
		{
			strTemp.replace(strTemp.find(L"//"), 1, L"\\");
		}

		ZeroMemory(szPath, MAX_PATH);
		SHGetSpecialFolderPath(NULL, szPath, CSIDL_LOCAL_APPDATA, FALSE);
		strPath = szPath;
		if (strPath.rfind(L'\\') != strPath.size())
		{
			strPath += L"\\";
		}
		strPath += L"Mozilla\\Firefox\\";
		strPath += strTemp;
		strPath += L"\\cache";

		strResult = strPath.c_str();
		goto Exit0;
	}
    else if ( CString("sogou").CompareNoCase(pszName) == 0 )
    {
        std::wstring strPath;
        std::wstring strTemp;
        WCHAR szPath[MAX_PATH] = {0};
        SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA, FALSE);
        strTemp = szPath;
        if ( strTemp.rfind(L'\\') != strTemp.size())
        {
            strTemp += L"\\";
        }
        strTemp += L"SogouExplorer\\CommCfg.xml";

        strResult = L"%sogou%";
        TiXmlDocument xmlDoc;
        const TiXmlElement *pXmlSogou = NULL;
        const TiXmlElement *pXmlGeneral = NULL;
        if (!xmlDoc.LoadFile(UnicodeToAnsi(strTemp.c_str()).c_str(), TIXML_ENCODING_UTF8))
            goto Exit0;
        pXmlSogou = xmlDoc.FirstChildElement("main");
        if (!pXmlSogou)
            goto Exit0;
        pXmlGeneral = pXmlSogou->FirstChildElement("Item");
        if (pXmlGeneral && pXmlGeneral->Attribute("videoacccachepath"))
        {
            const char* szTmp = pXmlGeneral->Attribute("videoacccachepath");
            if(!szTmp)
                strResult = L"%sogou%";
            else 
                strResult = Utf8ToUnicode(szTmp).c_str();
        }
        // 过滤根目录
        if (strResult.GetLength() <= 3)
            strResult = L"%sogou%";
        goto Exit0;
    }
    else if (CString("usertemp").CompareNoCase(pszName) == 0)
    {
        TCHAR szBuffer[MAX_PATH] = { 0 };
        CString strPath;
        CString strEnvName = L"%TEMP%";
        CString strEnvPath;

        ExpandEnvironmentStrings(strEnvName, strEnvPath.GetBuffer(MAX_PATH), MAX_PATH);
        strEnvPath.ReleaseBuffer();
        
        StandardPath(strEnvPath);
    
        UINT uResult = GetSystemDirectory(szBuffer, MAX_PATH);

        if (uResult < 3 || szBuffer[1] != TEXT(':') || szBuffer[2] != TEXT('\\'))
        {
            goto Exit0;     
        }
        szBuffer[3] = TEXT('\0');
        strPath += szBuffer;
        memset(szBuffer, 0, sizeof(szBuffer));
        DWORD MaxSize = sizeof(szBuffer);
        GetUserName(szBuffer, &MaxSize);

        if (KGetWinVersion() >= 4) 
        {
            strPath += L"Users\\"; 
            strPath += szBuffer; 
            strPath += L"\\AppData\\Local\\Temp\\";
        }
        else
        {
            strPath += L"Documents and Settings\\"; 
            strPath += szBuffer; 
            strPath += L"\\Local Settings\\Temp\\";
        }
        //
        if (strPath.CompareNoCase(strEnvPath) == 0 
            || strPath.Find(strEnvPath) != -1
            || strEnvPath.Find(strPath) != -1)
        {
            strResult = L"";
        }
        else
        {
            strResult = strPath;
        }
        goto Exit0;
    }
    else if (CString("wintemp").CompareNoCase(pszName) == 0)
    {
        DWORD len = sizeof(szLongPathBuffer);
        GetRegistryValue(HKEY_LOCAL_MACHINE,
            L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",
            L"TEMP",
            NULL,
            (LPBYTE)szLongPathBuffer,
            &len
            );
        if (wcslen(szLongPathBuffer) == 0)
        {
            strResult = L"";
        }
        else
        {
            if (CString("%SystemRoot%\\TEMP").CompareNoCase(szLongPathBuffer) == 0)
            {
                strResult = L"";
            }
            else
            {
                //解析环境变量
                CString strWinPath = szLongPathBuffer;

                int nFirstPos  = 0; 
                int nSecondPos = 0;
                BOOL bFind = FALSE;

                bFind = FindEnvironmentPos(strWinPath, nFirstPos, nSecondPos);
                
                if (bFind)
                {
                    CString strEnvName;
                    CString strEnvPath;
                    CString strLeft;
                    CString strRight;
                    strLeft = strWinPath.Left(nFirstPos);
                    strEnvName = strWinPath.Mid(nFirstPos, nSecondPos - nFirstPos + 1);
                    strRight = strWinPath.Mid(nSecondPos + 1);

                    ExpandEnvironmentStrings(strEnvName, strEnvPath.GetBuffer(MAX_PATH), MAX_PATH);
                    strEnvPath.ReleaseBuffer();
                    strResult += strLeft;
                    strResult += strEnvPath;
                    strResult += strRight;

                    UINT uResult = GetWindowsDirectory(szBuffer, MAX_PATH);

                    if(szBuffer[wcslen(szBuffer)-1] == _T('\\'))
                        szBuffer[wcslen(szBuffer)-1] = _T('\0');

                    CString strNormal = szBuffer;

                    strNormal += L"\\Temp\\";

                    StandardPath(strResult);

                    // 根目录跳过 和 子目录过滤,同时过滤 
                    if (strResult.GetLength() <= 3 
                        || strResult.Find(strNormal) != -1
                        || strNormal.Find(strResult) != -1)
                    {
                        strResult = L"";
                    }

                }
                else
                {
                    strResult = szLongPathBuffer;
                }
            }
        }
        goto Exit0;
    }
    else if (CString("office").CompareNoCase(pszName) == 0)
    {
        CString strDriverName;
        std::vector<CString> vecDrive;
        std::vector<CString>::iterator ite;

        TCHAR   szDriverName[500]; 

        DWORD nLength = GetLogicalDriveStrings(sizeof(szDriverName), szDriverName); 

        for (int i = 0; i < (int)nLength; i++) 
        { 
            if (szDriverName[i] != L'\0')
            {
                strDriverName += szDriverName[i]; 
            }
            else 
            { 
                strDriverName = strDriverName.Left(strDriverName.GetLength() - 1); 
                vecDrive.push_back(strDriverName); 
                strDriverName = ""; 
            } 
        }

        if (vecDrive.size() <= 0)
            goto Exit0;

        // 枚举盘符
        for (ite = vecDrive.begin(); ite != vecDrive.end(); ++ite)
        {
            CString strPath = (*ite) + _T("\\MSOCache");
            BOOL bRet = PathFileExists(strPath);

            if (bRet) 
            {
                strResult = strPath;
                break;
            }
        }
        goto Exit0;
    }
    else if (CString("qqmusic").CompareNoCase(pszName) == 0)
    {
        WCHAR szPath[MAX_PATH] = {0};
        std::wstring strPath;
        std::wstring strTemp;

        SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA, FALSE);
        strPath = szPath;

        if (strPath.rfind(L'\\') != strPath.size())
        {
            strPath += L"\\";
        }
        strPath += L"Tencent\\QQMusic\\CachePath.ini";
        IniEditor inif;
        inif.SetFile(strPath.c_str());
        strTemp = inif.ReadString(L"Cache", L"Path");
        if(strTemp.find(L"//") != -1)
        {
            strTemp.replace(strTemp.find(L"//"), 1, L"\\");
        }

        strResult += strTemp.c_str();

        if (strResult.IsEmpty())
            goto Exit0;

        if (strResult[strResult.GetLength() - 1] != _T('\\'))
            strResult += _T('\\');

        strResult += L"musiccache";

        goto Exit0;
    }
    else if (CString("kuwo").CompareNoCase(pszName) == 0)
    {
        WCHAR szPath[MAX_PATH] = {0};
        std::wstring strPath;
        std::wstring strTemp;

        SHGetSpecialFolderPath(NULL, szPath, CSIDL_COMMON_APPDATA, FALSE);
        strPath = szPath;

        if (strPath.rfind(L'\\') != strPath.size())
        {
            strPath += L"\\";
        }
        strPath += L"kuwo\\conf\\user\\config.ini";
        IniEditor inif;

        inif.SetFile(strPath.c_str());
        strTemp = inif.ReadString(L"Setting", L"temppath");
        if(strTemp.find(L"//") != -1)
        {
            strTemp.replace(strTemp.find(L"//"), 1, L"\\");
        }

        strResult = strTemp.c_str();

        goto Exit0;
    }
    else if (CString("ttplayer").CompareNoCase(pszName) == 0)
    {
        DWORD len = sizeof(szLongPathBuffer);
        TCHAR szDefault[MAX_PATH * 2] = { 0 };
        SHGetSpecialFolderPath(NULL, szDefault, CSIDL_APPDATA, FALSE);
        PathAppend(szDefault, L"TTPlayer\\cache");

        GetRegistryValue(HKEY_LOCAL_MACHINE,
            L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\TTPlayer",
            L"AppPath",
            NULL,
            (LPBYTE)szLongPathBuffer,
            &len
            );
        if(wcslen(szLongPathBuffer) == 0)
        {
            strResult = L"%ttplayer%";
        }
        else
        {
            ::PathRemoveFileSpec(szLongPathBuffer);
            ::PathAppend(szLongPathBuffer,L"TTPlayer.xml");
            TiXmlDocument xmlDoc;
            const TiXmlElement *pXmlTTPlayer = NULL;
            const TiXmlElement *pXmlGeneral = NULL;
            if (!xmlDoc.LoadFile(UnicodeToAnsi(szLongPathBuffer).c_str(), TIXML_ENCODING_UTF8))
                goto Exit0;

            pXmlTTPlayer = xmlDoc.FirstChildElement("ttplayer");
            if (!pXmlTTPlayer)
                goto Exit0;

            pXmlGeneral = pXmlTTPlayer->FirstChildElement("Network");
            if (pXmlGeneral)
            {
                const char* szTmp = pXmlGeneral->Attribute("CacheFolder");
                if(!szTmp)
                    strResult = L"%ttplayer%";
                else 
                    strResult = Utf8ToUnicode(szTmp).c_str();
            }
            
        }

        if (strResult.Find(szDefault) != -1 || strResult.GetLength() <= 3)
            strResult = L"%ttplayer%";

        goto Exit0;
    }
    else if (CString("ksafe").CompareNoCase(pszName) == 0)
    {
//         WCHAR szPath[MAX_PATH] = { 0 };
//         WCHAR szCmdline[MAX_PATH * 2] = { 0 };
//         ::GetModuleFileName(NULL, szPath, MAX_PATH);
// 
//         ::PathRemoveFileSpec(szPath);
//         std::wstring strIniPath = szPath;
//         std::wstring strTemp;
// 
//         strIniPath += L"\\cfg\\vulfix.ini";
// 
// //         IniEditor inif;
// // 
// //         inif.SetFile(strIniPath.c_str());
// //         strTemp = inif.ReadString(L"Main", L"downpath");
// //         if(strTemp.find(L"//") != -1)
// //         {
// //             strTemp.replace(strTemp.find(L"//"), 1, L"\\");
// //         }
// 
//         if (strTemp.length() == 0)
//         {
//             strResult = szPath;
//             strResult += L"\\hotfix";
//         }
//         else
//         {
//             strResult = strTemp.c_str();
//         }
        goto Exit0;
    }
    DWORD dwResult = GetEnvironmentVariable(pszName, szBuffer, MAX_PATH);
    if (dwResult > 0)
    {
        dwResult = 0;

        LPSTR pFileName = NULL;

        if (m_pfnGetLongPathName != NULL) 
            dwResult = m_pfnGetLongPathName(szBuffer, szLongPathBuffer, MAX_PATH);

        strResult = dwResult ? szLongPathBuffer : szBuffer;
    }
Exit0:
   
    return strResult;
}