Exemple #1
0
    ///////////////////////////////////////////////////////////////////////
    //  Name: DoNonSilentEnable
    //  Description:  Performs non-silent enable.
    /////////////////////////////////////////////////////////////////////////

    private void DoNonSilentEnable()
    {
        // Trust status for the URL.
        MFURLTrustStatus trustStatus = MFURLTrustStatus.Untrusted;

        HResult hr;
        string  sURL;              // Enable URL
        int     cchURL = 0;        // Size of enable URL in characters.

        IntPtr pPostData;          // Buffer to hold HTTP POST data.
        int    cbPostDataSize = 0; // Size of buffer, in bytes.

        // Get the enable URL. This is where we get the enable data for non-silent enabling.
        hr = m_pEnabler.GetEnableURL(out sURL, out cchURL, out trustStatus);
        MFError.ThrowExceptionForHR(hr);

        Debug.WriteLine(string.Format("Content enabler: URL = {0}", sURL));
        LogTrustStatus(trustStatus);

        if (trustStatus != MFURLTrustStatus.Trusted)
        {
            throw new COMException("The enabler URL is not trusted. Failing.", (int)HResult.E_FAIL);
        }

        // Start the thread that monitors the non-silent enable action.
        hr = m_pEnabler.MonitorEnable();
        MFError.ThrowExceptionForHR(hr);

        // Get the HTTP POST data
        hr = m_pEnabler.GetEnableData(out pPostData, out cbPostDataSize);
        MFError.ThrowExceptionForHR(hr);

        try
        {
            WebHelper m_webHelper = new WebHelper();

            // Open the URL and send the HTTP POST data.
            m_webHelper.OpenURLWithData(sURL, pPostData, cbPostDataSize, m_hwnd);
        }
        finally
        {
            Marshal.FreeCoTaskMem(pPostData);
        }
    }
Exemple #2
0
 private void LogTrustStatus(MFURLTrustStatus status)
 {
     Debug.WriteLine(status.ToString());
 }
Exemple #3
0
 private void LogTrustStatus(MFURLTrustStatus status)
 {
     Debug.WriteLine(status.ToString());
 }