Microsoft KB Archive/264460

= How To Subscribe to an Active Channel with the SubscriptionMgr Object =

Article ID: 264460

Article Last Modified on 5/11/2006

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 4.01 Service Pack 1
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer (Programming) 5.01 SP1
 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q264460



SUMMARY
The Subscription Manager Object manages subscriptions. The two interfaces exposed are ISubscriptionMgr and ISubscriptionMgr2. Both interfaces are used to enable a client program to control the subscription manager. This article describes how to call ISubscriptionMgr from Microsoft Visual C++.



MORE INFORMATION
The following sample code calls the CoCreateInstance function on the Subscription Manager Object to allow the user to subscribe to the test channel from a console application:


 * 1) include 
 * 2) include 

void main {   ISubscriptionMgr *pSubscriptionMgr; CoInitialize(NULL); HRESULT hr = CoCreateInstance(CLSID_SubscriptionMgr,                   NULL,                    CLSCTX_INPROC_SERVER,                    IID_ISubscriptionMgr,                    (void**)&pSubscriptionMgr);

if (SUCCEEDED(hr)) {                BOOL Bool; // SUBSCRIPTIONINFO contains the details of a subscription. SUBSCRIPTIONINFO sinfo;

BSTR bstrURL = SysAllocString(L&quot;http://test.microsoft.com/tst.cdf&quot;); BSTR bstrName = SysAllocString(L&quot;Test Channel&quot;); // TASK_TRIGGER structure defines the times to run a scheduled work item TASK_TRIGGER trig; // SYSTEMTIME structure represents a date and time using individual members // for the month, day, year, weekday, hour, minute, second, and millisecond SYSTEMTIME st;

// Allocate memory memset(&sinfo, 0, sizeof(sinfo)); sinfo.cbSize = sizeof(sinfo);

// Fill in current local date and time GetLocalTime(&st); trig.wBeginYear = st.wYear; trig.wBeginMonth = st.wMonth; trig.wBeginDay = st.wDay; trig.wStartHour = st.wHour; trig.wStartMinute = st.wMinute; trig.TriggerType = TASK_TIME_TRIGGER_DAILY; trig.Type.Daily.DaysInterval = 1;

sinfo.fUpdateFlags = SUBSINFO_ALLFLAGS; sinfo.schedule = SUBSSCHED_AUTO; sinfo.pTrigger = &trig; sinfo.dwRecurseLevels = 3; sinfo.fWebcrawlerFlags = WEBCRAWL_DONT_MAKE_STICKY; sinfo.bMailNotification = false; sinfo.bGleam = true; sinfo.bChangesOnly = false; sinfo.bNeedPassword = false; sinfo.fChannelFlags = CHANNEL_AGENT_DYNAMIC_SCHEDULE; sinfo.bstrFriendlyName = SysAllocString(L&quot;Test Create Subscription&quot;); sinfo.dwMaxSizeKB = 100; sinfo.subType = SUBSTYPE_CHANNEL; sinfo.dwReserved = 0;

hr = pSubscriptionMgr->IsSubscribed(bstrURL, &Bool); hr = pSubscriptionMgr->CreateSubscription(NULL,                               bstrURL,                                bstrName,                                CREATESUBS_ADDTOFAVORITES,                                SUBSTYPE_CHANNEL,                                &sinfo); SysFreeString (bstrURL); }      CoUninitialize; }

