コード例 #1
0
ファイル: bigfilehelper.cpp プロジェクト: dreamsxin/PcManager
// 获得360浏览器的下载目录
BOOL bigfilehelper::Get360DownloadDirs(std::vector<CString>& vDirs)
{
    WCHAR szPath[MAX_PATH] = {0};
    BOOL bRet = FALSE;
    CString szPathFull;
    WCHAR szAppDataPath[MAX_PATH] = { 0 };

    szAppDataPath[0] = GetSystemDrive();
    wcscat(szAppDataPath,L":\\Downloads");
    vDirs.push_back(szAppDataPath);

    bRet = SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA, FALSE);
    szPathFull = szPath;
    szPathFull += _T("\\360se\\extensions\\ExtDownload\\ExtDownload.ini");

    WCHAR szRecord[MAX_PATH] = {0};

    GetPrivateProfileString(L"Download", L"UserDefinePath", NULL, szRecord, MAX_PATH - 1, szPathFull);
    CString szFull = szRecord;

    if (_wcsicmp(szRecord, L"") == 0)
    {
        return FALSE;
    }
    if(szFull.GetAt(0)==GetSystemDrive()||szFull[0]==GetSystemDrive()-32||szFull[0]==GetSystemDrive()+32)
        vDirs.push_back(szFull);
    else 
        return FALSE;
    return TRUE;
}
コード例 #2
0
ファイル: bigfilehelper.cpp プロジェクト: dreamsxin/PcManager
// 获得迅雷的下载目录
BOOL bigfilehelper::GetXunLeiDownloadDirs(std::vector<CString>& vDirs)
{
    BOOL bRet = TRUE;
    TCHAR szLongPathBuffer[MAX_PATH] = { 0 };
    DWORD len = sizeof(szLongPathBuffer);

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

    GetRegistryValue(HKEY_CURRENT_USER,
        L"Software\\Thunder Network\\Thunder",
        L"DefaultPath",
        NULL,
        (LPBYTE)szLongPathBuffer,
        &len
        );
    if(wcslen(szLongPathBuffer) == 0)
        bRet = FALSE;
    else 
    {
        if(szLongPathBuffer[0]==GetSystemDrive()||szLongPathBuffer[0]==GetSystemDrive()-32||szLongPathBuffer[0]==GetSystemDrive()+32)
            vDirs.push_back(szLongPathBuffer);
        else bRet = FALSE;

    }
    return bRet;
}
コード例 #3
0
ファイル: bigfilehelper.cpp プロジェクト: dreamsxin/PcManager
// 获得QQ旋风的下载目录
BOOL bigfilehelper::GetQQDownLoadDownloadDirs(std::vector<CString>& vDirs)
{
    BOOL retval = FALSE;
    BOOL fRetCode;
    WCHAR szAppDataPath[MAX_PATH] = { 0 };
    WCHAR szCachePath[MAX_PATH] = { 0 };
    CString szFilePath = L"";
    DWORD dwRetCode;

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

    fRetCode = SHGetSpecialFolderPath(NULL, szAppDataPath, CSIDL_APPDATA, FALSE);
    if (!fRetCode)
        goto clean0;

    PathAppend(szAppDataPath, _T("QQDownload\\"));
    if (GetFileAttributes(szAppDataPath) == INVALID_FILE_ATTRIBUTES)
        goto clean0;

    fRetCode = FindUserConfigInDir(szAppDataPath, szFilePath);
    if(!fRetCode || szFilePath.GetLength() == 0)
    {
        goto clean0;
    }

    dwRetCode = GetPrivateProfileString(
        _T("TaskInfo"),
        _T("DefaultSavePath"),
        _T(""),
        szCachePath, 
        MAX_PATH,
        szFilePath.GetBuffer()
        );
    if (!dwRetCode)
        goto clean0;

    if (GetFileAttributes(szCachePath) == INVALID_FILE_ATTRIBUTES)
        goto clean0;

    if(szCachePath[0]==GetSystemDrive()||szCachePath[0]==GetSystemDrive()-32||szCachePath[0]==GetSystemDrive()+32)
        vDirs.push_back(szCachePath);
    else goto clean0;

    retval = TRUE;

clean0:
    return retval;
}
コード例 #4
0
ファイル: bigfilehelper.cpp プロジェクト: dreamsxin/PcManager
// 获得马桶的下载目录
BOOL bigfilehelper::GetMaxmonthDownloadDirs(std::vector<CString>& vDirs)
{
    KSearchSoftwareStruct sss;
    wstring strPath;
    BOOL bRet = FALSE;
    CString szPathFull;
    WCHAR szPath[MAX_PATH] = {0};
    WCHAR szAppDataPath[MAX_PATH] = {0};
    
    szAppDataPath[0] = GetSystemDrive();
    wcscat(szAppDataPath,L":\\MxDownload");
    vDirs.push_back(szAppDataPath);

    sss.pszMainFileName      = TEXT( "Maxthon.exe" );
    sss.hRegRootKey = HKEY_CURRENT_USER;
    sss.pszRegSubKey = _T("SOFTWARE\\Maxthon2");
    sss.pszPathValue = _T("Folder");

    bRet = SearchSoftwarePath( &sss, strPath );
    wcscpy(szPath, strPath.c_str());
    ::PathRemoveFileSpec(szPath);
    szPathFull = szPath;

    szPathFull += _T("\\SharedAccount\\Config\\Downloader.ini");

    WCHAR szRecord[MAX_PATH] = {0};

    for (int i = 0; i < 8; i++)
    {
        CString strTemp;
        strTemp.Format(_T("%d"), i);
        GetPrivateProfileString(L"COMBOX_HIS", strTemp, NULL, szRecord, MAX_PATH - 1, szPathFull);
        if (_wcsicmp(szRecord, L"") == 0)
        {
            break;
        }
        CString szFull = szRecord;
        if(szFull.GetAt(0)==GetSystemDrive()||szFull[0]==GetSystemDrive()-32||szFull[0]==GetSystemDrive()+32)
            vDirs.push_back(szFull);

    }
    return TRUE;
}
コード例 #5
0
ファイル: bigfilehelper.cpp プロジェクト: dreamsxin/PcManager
// 获得世界之窗的下载目录
BOOL bigfilehelper::GetTheworldDownloadDirs(std::vector<CString>& vDirs)
{
    KSearchSoftwareStruct sss;
    wstring strPath;
    BOOL bRet = FALSE;
    CString szPathFull;
    WCHAR szPath[MAX_PATH] = {0};

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

    sss.pszMainFileName      = TEXT( "TheWorld.exe" );
    sss.hRegRootKey = HKEY_LOCAL_MACHINE;
    sss.pszRegSubKey = _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\TheWorld.exe");
    sss.pszPathValue = _T("Path");
    sss.pszUninstallListName = _T("世界之窗浏览器");

    bRet = SearchSoftwarePath( &sss, strPath );
    wcscpy(szPath, strPath.c_str());
    ::PathRemoveFileSpec(szPath);
    szPathFull = szPath;

    szPathFull += _T("\\TheWorld.ini");

    WCHAR szRecord[MAX_PATH] = {0};

    for (int i = 0; i < 8; i++)
    {
        CString strTemp;
        strTemp.Format(_T("Path%d"), i);
        GetPrivateProfileString(L"Download", strTemp, NULL, szRecord, MAX_PATH - 1, szPathFull);
        if (_wcsicmp(szRecord, L"") == 0)
        {
            break;
        }
        CString szFull = szRecord;
        if(szFull.GetAt(0)==GetSystemDrive()||szFull[0]==GetSystemDrive()-32||szFull[0]==GetSystemDrive()+32)
            vDirs.push_back(szFull);
    }
    return TRUE;
}
コード例 #6
0
ファイル: bigfilehelper.cpp プロジェクト: dreamsxin/PcManager
// 获得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;
}
コード例 #7
0
ファイル: bigfilehelper.cpp プロジェクト: dreamsxin/PcManager
// 获得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;
}
コード例 #8
0
ファイル: bigfilehelper.cpp プロジェクト: dreamsxin/PcManager
BOOL bigfilehelper::GetChromeDownloadDirs(std::vector<CString>& vDirs)
{
    WCHAR szPath[MAX_PATH] = {0};
    BOOL bRet = FALSE;
    CString szPathFull;
    CString szPathFullEx;
    CString szTarget;
    int nPos = -1;
    CString strPath = L"";
    WCHAR szAppDataPath[MAX_PATH] = { 0 };
    
    bRet = SHGetSpecialFolderPath(NULL, szAppDataPath, CSIDL_PERSONAL, FALSE);
    if(bRet)
    {
        wcscat(szAppDataPath,L"\\Downloads");
        if(szAppDataPath[0]==GetSystemDrive())
            vDirs.push_back(szAppDataPath);
    }

    bRet = SHGetSpecialFolderPath(NULL, szPath, CSIDL_LOCAL_APPDATA, FALSE);

    //bRet = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_DEFAULT, szPath);;
    szPathFull = szPath;
    szPathFullEx = szPath;
    szPathFullEx += _T("\\Google\\Chrome\\User Data\\Default\\Preferences");
    szPathFull += _T("\\Google\\Chrome\\User Data\\Default");

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

    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"default_directory");
        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(szRecord, L"") == 0)
    // 	{
    // 		bRet = FALSE;
    // 		goto _Exit;
    // 	}

    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;
    bRet = TRUE;
_Exit:

    if (pBuf)
    {
        delete []pBuf;
        pBuf = NULL;
    }
    if (pFile)
    {
        fclose(pFile);
        pFile = NULL;
    }
    return bRet;
}
コード例 #9
0
ファイル: bigfilehelper.cpp プロジェクト: dreamsxin/PcManager
BOOL bigfilehelper::GetAutoDestDirFromSize(CString& strDir)
{
    BOOL retval = FALSE;
    CAtlArray<TCHAR> buffer;
    TCHAR* pBuffer = NULL;
    DWORD dwSize;
    CAtlList<CString> logicalDrvs;
    CString strDrv;
    POSITION pos = NULL;
    POSITION max_size_pos = NULL;
    ULONGLONG uMaxSize = 0;
    DWORD dwSectorsPerCluster;
    DWORD dwBytesPerSector;
    DWORD dwNumberOfFreeClusters;
    DWORD dwTotalNumberOfClusters;
    CString strSysDrv;
    TCHAR szVolName[MAX_PATH+1] = { 0 };
    TCHAR szFileSystem[MAX_PATH+1] = { 0 };
    BOOL fRetCode;

    SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);

    if (!GetSystemDrive(strSysDrv))
        goto clean0;

    buffer.SetCount(512);
    pBuffer = buffer.GetData();
    dwSize = (DWORD)buffer.GetCount();
    memset(pBuffer, 0, dwSize * sizeof(TCHAR));
    dwSize = GetLogicalDriveStrings(dwSize, buffer.GetData());

    if (dwSize > 2) 
    {
        strDrv = pBuffer;
        logicalDrvs.AddTail(strDrv);

        for (DWORD i = 3; i < dwSize; ++i) 
        {
            if (pBuffer[i] != 0 && pBuffer[i - 1] == 0) 
            {
                strDrv = pBuffer + i;
                logicalDrvs.AddTail(strDrv);
            }
        }
    }

    pos = logicalDrvs.GetHeadPosition();
    while (pos)
    {
        POSITION current = pos;
        CString _drv = logicalDrvs.GetNext(pos);
        _drv.MakeLower();
        if (_drv == _T("a:\\") || _drv == _T("b:\\"))
        {
            logicalDrvs.RemoveAt(current);
            continue;
        }

        UINT uType = GetDriveType(_drv);
        if (uType != DRIVE_FIXED &&
            uType != DRIVE_REMOVABLE)
        {
            logicalDrvs.RemoveAt(current);
            continue;
        }

        if (strSysDrv.CompareNoCase(_drv)==0)
        {
            logicalDrvs.RemoveAt(current);
            continue;
        }

        RtlZeroMemory(szVolName, sizeof(szVolName));
        RtlZeroMemory(szFileSystem, sizeof(szFileSystem));
        fRetCode = GetVolumeInformation(
            _drv,
            szVolName,
            MAX_PATH+1,
            NULL,
            NULL,
            NULL,
            szFileSystem,
            MAX_PATH+1
            );
        if (!fRetCode)
        {
            logicalDrvs.RemoveAt(current);
            continue;
        }
    }

    pos = logicalDrvs.GetHeadPosition();
    while (pos)
    {
        POSITION current = pos;
        const CString& _drv = logicalDrvs.GetNext(pos);
        BOOL fRetCode = GetDiskFreeSpace(
            _drv,
            &dwSectorsPerCluster,
            &dwBytesPerSector,
            &dwNumberOfFreeClusters,
            &dwTotalNumberOfClusters
            );
        if (!fRetCode)
            continue;

        ULONGLONG uCurrentFreeSize = (ULONGLONG)dwNumberOfFreeClusters * dwSectorsPerCluster * dwBytesPerSector;
        if (uCurrentFreeSize > uMaxSize)
        {
            max_size_pos = current;
            uMaxSize = uCurrentFreeSize;
        }
    }
    if (max_size_pos==NULL)
        goto clean0;
    strDir = logicalDrvs.GetAt(max_size_pos);
    strDir += _T("系统盘大文件");

    retval = TRUE;

clean0:
    return retval;
}
コード例 #10
0
ファイル: bigfilehelper.cpp プロジェクト: dreamsxin/PcManager
// 获得比特彗星的下载目录
BOOL bigfilehelper::GetBitCometDownloadDirs(std::vector<CString>& vDirs)
{
    BOOL retval = FALSE;
    TiXmlDocument xmlDoc;
    const TiXmlElement *pBT = NULL;
    const TiXmlElement *pSet = NULL;
    const TiXmlElement *pDownLoad = NULL;
    const char* szDefaultDownPath = NULL;
    CString strDirs;
    int pos = -1;
    TCHAR szAppPath[MAX_PATH] = { 0 };
    ULONG dwLength = MAX_PATH;
    CRegKey regKey;
    LONG lRetCode;

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

    lRetCode = regKey.Open(HKEY_CURRENT_USER, _T("Software\\BitComet"), KEY_READ);
    if (lRetCode)
        goto clean0;

    lRetCode = regKey.QueryStringValue(NULL, szAppPath, &dwLength);
    if (lRetCode)
        goto clean0;

    PathRemoveFileSpec(szAppPath);
    PathAppend(szAppPath, _T("BitComet.xml"));

    if (GetFileAttributes(szAppPath) == INVALID_FILE_ATTRIBUTES)
        goto clean0;

    if (!xmlDoc.LoadFile(UnicodeToAnsi(szAppPath).c_str(), TIXML_ENCODING_UTF8))
        goto clean0;

    pBT = xmlDoc.FirstChildElement("BitComet");
    if (!pBT)
        goto clean0;

    pSet = xmlDoc.FirstChildElement("Settings");
    if (!pSet)
        goto clean0;

    pDownLoad = xmlDoc.FirstChildElement("DefaultDownloadPath");
    if (!pDownLoad)
        goto clean0;


    szDefaultDownPath = pDownLoad->GetText();
    if (!szDefaultDownPath)
        goto clean0;

    strDirs = Utf8ToUnicode(szDefaultDownPath).c_str();
    if (GetFileAttributes(strDirs) != INVALID_FILE_ATTRIBUTES)
    { 
        if(strDirs.GetAt(0)==GetSystemDrive()||strDirs.GetAt(0)==GetSystemDrive()-32||strDirs.GetAt(0)==GetSystemDrive()+32)
            vDirs.push_back(strDirs);
        else goto clean0;
    }
    retval = TRUE;

clean0:
    return retval;
}
コード例 #11
0
ファイル: startrec.c プロジェクト: Strongc/reactos
static LRESULT
LoadOSList(HWND hwndDlg, PSTARTINFO pStartInfo)
{
    DWORD dwBufSize;
    WCHAR *szSystemDrive;
    HINF hInf;

    dwBufSize = GetSystemDrive(&szSystemDrive);
    if (dwBufSize == 0)
        return FALSE;

    wcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
    wcscat(pStartInfo->szFreeldrIni, L"\\freeldr.ini");

    if (PathFileExistsW(pStartInfo->szFreeldrIni))
    {
        /* Free resource previously allocated by GetSystemDrive() */
        HeapFree(GetProcessHeap(), 0, szSystemDrive);
        /* freeldr.ini exists */
        hInf = SetupOpenInfFileW(pStartInfo->szFreeldrIni,
                                 NULL,
                                 INF_STYLE_OLDNT,
                                 NULL);

        if (hInf != INVALID_HANDLE_VALUE)
        {
            LoadFreeldrSettings(hInf, hwndDlg);
            SetupCloseInfFile(hInf);
            pStartInfo->iFreeLdrIni = 1;
            return TRUE;
        }
        return FALSE;
    }

    /* Try loading boot.ini settings */
    wcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
    wcscat(pStartInfo->szFreeldrIni, L"\\boot.ini");

    /* Free resource previously allocated by GetSystemDrive() */
    HeapFree(GetProcessHeap(), 0, szSystemDrive);

    if (PathFileExistsW(pStartInfo->szFreeldrIni))
    {
        /* Load boot.ini settings */
        hInf = SetupOpenInfFileW(pStartInfo->szFreeldrIni,
                                 NULL,
                                 INF_STYLE_OLDNT,
                                 NULL);

        if (hInf != INVALID_HANDLE_VALUE)
        {
            LoadBootSettings(hInf, hwndDlg);
            SetupCloseInfFile(hInf);
            pStartInfo->iFreeLdrIni = 2;
            return TRUE;
        }

        return FALSE;
    }

    return FALSE;
}