int Run()

in src/VSIXBootstrapper.Shared/VSIXBootstrapper.h [51:106]


int Run(
    _In_ HINSTANCE hInstance,
    _In_ LPWSTR lpCmdLine,
    _In_ int nCmdShow)
{
    using namespace std;

    Resources<_Traits> resources(hInstance);
    auto quiet = true;

    try
    {
        // Determine whether we should ever show UI.
        CommandLine<_Traits> args(lpCmdLine);
        quiet = args.IsQuiet() || SW_HIDE == nCmdShow;

        vector<function<wstring()>> lookups
        {
            FromConfiguration<_Traits>,
            bind(FromRegistry<_Traits>, L"14.0"),
            bind(FromRegistry<_Traits>, L"12.0"),
            bind(FromRegistry<_Traits>, L"11.0"),
            bind(FromRegistry<_Traits>, L"10.0"),
        };

        for (const auto& lookup : lookups)
        {
            path path = lookup();
            if (!path.empty() && _Traits::IOFileExists(path.append(g_wszFileName).c_str()))
            {
                Process<_Traits> p(nCmdShow, path.c_str(), lpCmdLine);
                p.Wait();

                return p.GetExitCode();
            }
        }

        // We didn't find it so return an error.
        ShowError<_Traits>(resources, quiet, IDS_NOTFOUND);
        return ERROR_FILE_NOT_FOUND;
    }
    catch (system_error& ex)
    {
        const auto code = ex.code().value();

        ShowError<_Traits>(resources, quiet, IDS_SYSTEM_ERROR, code, ex.what());
        return code;
    }
    catch (exception& ex)
    {
        ShowError<_Traits>(resources, quiet, IDS_ERROR, ex.what());
        return GENERIC_ERROR;
    }

    return GENERIC_ERROR;
}