HOWTO: Get WinInet Information from a URL Moniker Binding

Last reviewed: January 19, 1998
Article ID: Q176787
The information in this article applies to:
  • Microsoft ActiveX SDK, version 1.0
  • Internet Client SDK, versions 4.0, 4.01

SUMMARY

Programs that use URL Monikers to download data but need to obtain extra low-level WinInet information about the download can use the IWinInetHttpInfo and IWinInetInfo interfaces.

The IWinInetHttpInfo interface implemented by the binding object can be used to make the equivalent of HttpQueryInfo calls. In the same fashion, IWinInetInfo can be used to make the equivalent of InternetQueryOption calls.

MORE INFORMATION

The user of a URL Moniker receives a reference to the IBinding interface of the binding object in the IBindStatusCallback::OnStartBinding interface. When binding to an HTTP server, the binding object supports the IWinInetHttpInfo interface for obtaining HTTP-specific information, such as HTTP headers. The binding object also supports the IWinInetInfo interface for obtaining Internet options such as the name of the file downloaded by a URL moniker binding. Both interfaces support the QueryInfo method. QueryInfo basically forwards the call to the standard WinInet functions HttpQueryInfo and InternetQueryOption, respectively.

Here is a sample snippet of code from an IBindStatusCallback implementation that uses IWininetHttpInfo to retrieve the raw headers sent by the HTTP server. It then uses IWininetInfo to query for the name of the local data file returned by the download:

   // required includes:
   #include <urlmon.h>
   #include <wininet.h>

   STDMETHOD(OnStopBinding)(HRESULT hresult, LPCWSTR szError)
   {
      // m_spBinding is the IBinding interface passed in OnStartBinding

      if (!FAILED(hresult))
      {
         IWinInetHttpInfo* pInfo;
         char buff[1024];
         DWORD dwBuffSize = 1024;
         HRESULT hr = m_spBinding->QueryInterface(IID_IWinInetHttpInfo,
                                                  (void**)&pInfo);
         if (!FAILED(hr))
         {
            BOOL bResult = pInfo->QueryInfo(HTTP_QUERY_RAW_HEADERS,
                                            buff, &dwBuffSize, 0, NULL);
         }
         pInfo->Release();
      }

      if (!FAILED(hresult))
      {
         IWinInetInfo* pInfo;
         char buff[1024];
         DWORD dwBuffSize = 1024;
         HRESULT hr = m_spBinding->QueryInterface(IID_IWinInetInfo,
                                                  (void**)&pInfo);
         if (!FAILED(hr))
         {
            BOOL bResult = pInfo
            ->QueryOption(INTERNET_OPTION_DATAFILE_NAME,
                                             buff, &dwBuffSize);
         }
         pInfo->Release();
      }

   // ...
   return S_OK;
   }

For complete information on the parameters available to IWinInetHttpInfo::QueryInfo and IWinInetInfo::QueryOption, review the Internet Client SDK documentation for the WinInet functions HttpQueryInfo and InternetQueryOption, respectively.

REFERENCES

Internet Client SDK: Internet Tools & Technologies; Monikers, URLs, Security Zones, and Pluggable Protocols

Internet Client SDK: Internet Tools & Technologies; WinInet API

Keywords          : AXSDKUrlMon kbcode
Technology        : kbInetDev
Version           : WINDOWS:1.0,4.0,4.01
Platform          : WINDOWS
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 19, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.