How To Enumerate Channels in Internet Explorer 4.0 (178851)
The information in this article applies to:
- Microsoft Internet Explorer (Programming) 4.0
- Microsoft Internet Explorer (Programming) 4.01
This article was previously published under Q178851 SUMMARY
With 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 INFORMATION
The 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();
Modification Type: | Minor | Last Reviewed: | 7/1/2004 |
---|
Keywords: | kbhowto KB178851 |
---|
|