Ejemplo n.º 1
0
bool ExtractParams(CString data, CStringList &params)
{
    CString param;
    params.RemoveAll();
    for(int i = 0; ; i++)
    {
        if(ExtractParam(data, param, i))
        {
            params.AddTail(param);
        }
        else
        {
            break;
        }
    }
    return !params.IsEmpty();
}
Ejemplo n.º 2
0
bool ExtractParams(CString data, RectI &rect)
{
    CString param;
    for(int i = 0; i < 4; i++)
    {
        if(ExtractParam(data, param, i))
        {
            int n  = _wtoi(param.GetBuffer());
            switch(i)
            {
            case 0:
            {
                rect.X = n;
            }
            break;

            case 1:
            {
                rect.Y = n;
            }
            break;

            case 2:
            {
                rect.Width = n;
            }
            break;

            case 3:
            {
                rect.Height = n;
            }
            break;
            }
        }
        else
        {
            return false;
        }
    }
    return true;
}
Ejemplo n.º 3
0
CString ExtractParam(CString data, int index)
{
    CString param;
    ExtractParam(data, param, index);
    return param;
}
BOOL ParseAndValidateCommandLine(PWSTR *ppszArgs, int iArgs, ACTION_TYPE *at, KNOWNFOLDERID *pkfid,
                                 KNOWNFOLDER_DEFINITION *pkfd, PWSTR *ppszFindForPath)
{
    BOOL fSuccess = TRUE;
    *at = ACT_UNDEFINED;
    *ppszFindForPath = NULL;

    for (int i = 0; fSuccess && (i < iArgs); ++i)
    {
        if (wcsstr(ppszArgs[i], SZ_CLA_REGISTER))
        {
            *at = ACT_REGISTER;
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_ENUM))
        {
            *at = ACT_ENUM;
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_UNREGISTER))
        {
            *at = ACT_UNREGISTER;
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_CLEAN))
        {
            *at = ACT_CLEAN;
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_SHOW_USAGE))
        {
            *at = ACT_SHOW_USAGE;
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_CATEGORY))
        {
            PWSTR pszCat;
            fSuccess = ExtractParam(SZ_CLA_CATEGORY, ppszArgs[i], &pszCat);
            if (fSuccess)
            {
                fSuccess = ArgToCategory(pszCat, &pkfd->category);
                CoTaskMemFree(pszCat);
            }
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_DEFFLAG))
        {
            PWSTR pszCat;
            fSuccess = ExtractParam(SZ_CLA_DEFFLAG, ppszArgs[i], &pszCat);
            if (fSuccess)
            {
                KF_DEFINITION_FLAGS flags;
                fSuccess = ArgToFlag(pszCat, &flags);
                if (fSuccess)
                {
                    pkfd->kfdFlags |= flags;
                }
                CoTaskMemFree(pszCat);
            }
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_ID))
        {
            PWSTR pszKFID;
            fSuccess = ExtractParam(SZ_CLA_ID, ppszArgs[i], &pszKFID);
            if (fSuccess)
            {
                CLSIDFromString(pszKFID, pkfid);
                CoTaskMemFree(pszKFID);
            }
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_PSZNAME))
        {
            fSuccess = ExtractParam(SZ_CLA_PSZNAME, ppszArgs[i], &(pkfd->pszName));
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_PSZDESCRIPTION))
        {
            fSuccess = ExtractParam(SZ_CLA_PSZDESCRIPTION, ppszArgs[i], &(pkfd->pszDescription));
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_PSZRELPATH))
        {
            fSuccess = ExtractParam(SZ_CLA_PSZRELPATH, ppszArgs[i], &(pkfd->pszRelativePath));
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_PSZPARSENAME))
        {
            fSuccess = ExtractParam(SZ_CLA_PSZPARSENAME, ppszArgs[i], &(pkfd->pszParsingName));
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_PSZLOCALIZEDNAME))
        {
            fSuccess = ExtractParam(SZ_CLA_PSZLOCALIZEDNAME, ppszArgs[i], &(pkfd->pszLocalizedName));
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_PSZICON))
        {
            fSuccess = ExtractParam(SZ_CLA_PSZICON, ppszArgs[i], &(pkfd->pszIcon));
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_PSZTOOLTIP))
        {
            fSuccess = ExtractParam(SZ_CLA_PSZICON, ppszArgs[i], &(pkfd->pszTooltip));
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_PSZSECURITY))
        {
            fSuccess = ExtractParam(SZ_CLA_PSZSECURITY, ppszArgs[i], &(pkfd->pszSecurity));
        }
        else if (wcsstr(ppszArgs[i], SZ_CLA_FINDFORPATH))
        {
            *at = ACT_FIND_FOR_PATH;
            fSuccess = ExtractParam(SZ_CLA_FINDFORPATH, ppszArgs[i], ppszFindForPath);
        }
    }

    return fSuccess;
}