How To Subscribe to an Active Channel with the SubscriptionMgr Object (264460)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 4.0
  • Microsoft Internet Explorer (Programming) 4.01
  • Microsoft Internet Explorer (Programming) 4.01 SP1
  • Microsoft Internet Explorer (Programming) 4.01 SP2
  • Microsoft Internet Explorer (Programming) 5
  • Microsoft Internet Explorer (Programming) 5.01
  • Microsoft Internet Explorer (Programming) 5.01 SP1
  • Microsoft Internet Explorer (Programming) 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:
#include <subsmgr.h>   
#include <mstask.h> 

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"http://test.microsoft.com/tst.cdf");
        BSTR bstrName = SysAllocString(L"Test Channel");
// 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"Test Create Subscription");
        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();   
}
				

REFERENCES

Microsoft Developer Network (MSDN) Web Workshop: MSDN Online Library: For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

175504 How To Determine Whether a User Is Subscribed to a Channel

For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:

Modification Type:MajorLast Reviewed:5/11/2006
Keywords:kbChannels kbhowto KB264460