HOWTO: Enumerate Channels in Internet Explorer 4.0Last reviewed: January 19, 1998Article ID: Q178851 |
The information in this article applies to:
SUMMARYWith the introduction of Active Channels in Internet Explorer 4.0, it may be desirable to enumerate all the channels installed in a system. This article demonstrates how to do this correctly using the new IChannelMgr and IEnumChannels interfaces documented in the Internet Client SDK.
MORE INFORMATIONThe following code enumerates the channels using the two interfaces, IChannelMgr and IEnumChannels, and adds every channel element retrieved into a listbox:
#define INITGUID #include <objbase.h> #include <initguid.h> #include <chanmgr.h> // This .h file defines the 2 interfaces CListBox *pList; HRESULT hr; IChannelMgr *pChannelMgr; IEnumChannels *pIEnumChannels; pList = (CListBox*)GetDlgItem(IDC_LIST1); if (FAILED(hr = CoInitialize(NULL))) return FALSE; hr = CoCreateInstance(CLSID_ChannelMgr, NULL, CLSCTX_INPROC_SERVER, IID_IChannelMgr, (void**)&pChannelMgr); hr = pChannelMgr->EnumChannels(CHANENUM_CHANNELFOLDER | CHANENUM_TITLE | CHANENUM_PATH | CHANENUM_URL, NULL, &pIEnumChannels); if (SUCCEEDED(hr)) { ASSERT(pIEnumChannels); CHANNELENUMINFO ci; while (S_OK == pIEnumChannels->Next(1, &ci, NULL)) { // Do something with the path here. TCHAR szTitle[200]; TCHAR szPath[200]; TCHAR szURL[200]; TCHAR szBuffer[500]; WideCharToMultiByte(CP_ACP, 0, ci.pszTitle, -1, szTitle, 200, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, ci.pszPath, -1, szPath, 200, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, ci.pszURL, -1, szURL, 200, NULL, NULL); //TRACE ("%s + %s + %s\r\n", szTitle, szPath, szURL); wsprintf (szBuffer,"%s (%s)",szTitle, szURL); pList->AddString (szBuffer); CoTaskMemFree(ci.pszTitle); CoTaskMemFree(ci.pszPath); CoTaskMemFree(ci.pszURL); } } pIEnumChannels->Release(); CoUninitialize(); REFERENCES"Internet Tools & Technologies\Information Delivery API" section of the Internet Client SDK (http://www.microsoft.com/msdn/sdk/inetsdk/help) Keywords : InetSDKInfoDev Technology : internet kbinetdev Version : WINDOWS:4.0,4.01 Platform : WINDOWS Issue type : kbhowto |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |