Exemplo n.º 1
0
  /**
   * Choose the appropriate launch type based on the user's previously chosen
   * host environment, along with system constraints.
   *
   * AHE_DESKTOP = 0, AHE_IMMERSIVE = 1
   */
  AHE_TYPE GetLaunchType()
  {
    AHE_TYPE ahe = GetLastAHE();
    Log(L"Previous AHE: %d", ahe);

    // Default launch settings from GetLastAHE() can be overriden by
    // custom parameter values we receive. 
    if (mRequestType == DESKTOP_RESTART) {
      Log(L"Restarting in desktop host environment.");
      return AHE_DESKTOP;
    } else if (mRequestType == METRO_RESTART) {
      Log(L"Restarting in metro host environment.");
      ahe = AHE_IMMERSIVE;
    } else if (mRequestType == METRO_UPDATE) {
      // Shouldn't happen from GetValue above, but might from other calls.
      ahe = AHE_IMMERSIVE;
    }

    if (ahe == AHE_IMMERSIVE) {
      if (!IsDefaultBrowser()) {
        Log(L"returning AHE_DESKTOP because we are not the default browser");
        return AHE_DESKTOP;
      }

      if (!IsDX10Available()) {
        Log(L"returning AHE_DESKTOP because DX10 is not available");
        return AHE_DESKTOP;
      }
    }
    return ahe;
  }
Exemplo n.º 2
0
  // IExecuteCommandApplicationHostEnvironment
  IFACEMETHODIMP GetValue(AHE_TYPE *aLaunchType)
  {
    Log(L"IExecuteCommandApplicationHostEnvironment::GetValue()");
    *aLaunchType = AHE_DESKTOP;
    mIsDesktopRequest = true;

    if (!mUnkSite) {
      Log(L"No mUnkSite.");
      return S_OK;
    }

    HRESULT hr;
    IServiceProvider* pSvcProvider = NULL;
    hr = mUnkSite->QueryInterface(IID_IServiceProvider, (void**)&pSvcProvider);
    if (!pSvcProvider) {
      Log(L"Couldn't get IServiceProvider service from explorer. (%X)", hr);
      return S_OK;
    }

    IExecuteCommandHost* pHost = NULL;
    // If we can't get this it's a conventional desktop launch
    hr = pSvcProvider->QueryService(SID_ExecuteCommandHost,
                                    IID_IExecuteCommandHost, (void**)&pHost);
    if (!pHost) {
      Log(L"Couldn't get IExecuteCommandHost service from explorer. (%X)", hr);
      SafeRelease(&pSvcProvider);
      return S_OK;
    }
    SafeRelease(&pSvcProvider);

    EC_HOST_UI_MODE mode;
    if (FAILED(pHost->GetUIMode(&mode))) {
      Log(L"GetUIMode failed.");
      SafeRelease(&pHost);
      return S_OK;
    }

    // 0 - launched from desktop
    // 1 - ?
    // 2 - launched from tile interface
    Log(L"GetUIMode: %d", mode);

    if (!IsDefaultBrowser()) {
      mode = ECHUIM_DESKTOP;
    }

    if (mode == ECHUIM_DESKTOP) {
      Log(L"returning AHE_DESKTOP");
      SafeRelease(&pHost);
      return S_OK;
    }
    SafeRelease(&pHost);

    if (!IsDX10Available()) {
      Log(L"returning AHE_DESKTOP because DX10 is not available");
      *aLaunchType = AHE_DESKTOP;
      mIsDesktopRequest = true;
    } else {
      Log(L"returning AHE_IMMERSIVE");
      *aLaunchType = AHE_IMMERSIVE;
      mIsDesktopRequest = false;
    }
    return S_OK;
  }