Microsoft KB Archive/175504: Difference between revisions

From BetaArchive Wiki
m (Text replacement - "<" to "<")
m (Text replacement - "&" to "&")
 
(2 intermediate revisions by the same user not shown)
Line 58: Line 58:


The code below demonstrates how this can be done using C++, from a console application:
The code below demonstrates how this can be done using C++, from a console application:
<pre class="codesample">#include <windows.h&gt;
<pre class="codesample">#include <windows.h>
#include <tchar.h&gt;
#include <tchar.h>
#include <iostream.h&gt;
#include <iostream.h>
#include <subsmgr.h&gt;
#include <subsmgr.h>
#include <stdio.h&gt;
#include <stdio.h>


void main()
void main()
Line 73: Line 73:
                                 CLSCTX_INPROC_SERVER,
                                 CLSCTX_INPROC_SERVER,
                                 IID_ISubscriptionMgr,
                                 IID_ISubscriptionMgr,
                                 (void**)&amp;pSubscriptionMgr);
                                 (void**)&pSubscriptionMgr);
   if (SUCCEEDED(hr))
   if (SUCCEEDED(hr))
   {
   {
       BOOL Bool;
       BOOL Bool;
       BSTR bstrURL =
       BSTR bstrURL =
         SysAllocString(L&quot;http://test.microsoft.com/tst.cdf&quot;);
         SysAllocString(L"http://test.microsoft.com/tst.cdf");
       hr = pSubscriptionMgr-&gt;IsSubscribed(bstrURL, &amp;Bool);
       hr = pSubscriptionMgr->IsSubscribed(bstrURL, &Bool);


       pSubscriptionMgr-&gt;Release();
       pSubscriptionMgr->Release();


       char szBuffer[250];
       char szBuffer[250];
Line 88: Line 88:
                           NULL);
                           NULL);
       if (Bool)
       if (Bool)
           wsprintf (szBuffer,&quot;YES, you are subscribed to %s\n&quot;,szURL);
           wsprintf (szBuffer,"YES, you are subscribed to %s\n",szURL);
       else
       else
           wsprintf (szBuffer,&quot;NOPE, you are NOT subscribed to %s\n&quot;,
           wsprintf (szBuffer,"NOPE, you are NOT subscribed to %s\n",
                     szURL);
                     szURL);
       cout << szBuffer;
       cout << szBuffer;
Line 101: Line 101:
=== Visual Basic - Using the ShellUIHelper Object ===
=== Visual Basic - Using the ShellUIHelper Object ===


The code below demonstrates how this can be done in a standard Visual Basic application. To use the ShellUIHelper object, use Project-&gt;References to add a reference to &quot;Microsoft Internet Controls.&quot;
The code below demonstrates how this can be done in a standard Visual Basic application. To use the ShellUIHelper object, use Project->References to add a reference to "Microsoft Internet Controls."
<pre class="codesample">Private Sub Form_Load()
<pre class="codesample">Private Sub Form_Load()
     Dim ShlHlpr As ShellUIHelper
     Dim ShlHlpr As ShellUIHelper
Line 107: Line 107:
     Set ShlHlpr = New ShellUIHelper
     Set ShlHlpr = New ShellUIHelper


     If ShlHlpr.IsSubscribed(&quot;http://test.microsoft.com/tst.cdf&quot;) Then
     If ShlHlpr.IsSubscribed("http://test.microsoft.com/tst.cdf") Then
         MsgBox &quot;You're Subscribed!&quot;
         MsgBox "You're Subscribed!"
     Else
     Else
         MsgBox &quot;You're not Subscribed!&quot;
         MsgBox "You're not Subscribed!"
     End If
     End If
End Sub
End Sub
Line 118: Line 118:


The code below demonstrates how this can be done, using JavaScript in an .htm page:
The code below demonstrates how this can be done, using JavaScript in an .htm page:
<pre class="codesample"><SCRIPT&gt;
<pre class="codesample"><SCRIPT>
   if (window.external.isSubscribed(&quot;http://test.microsoft.com/tst.cdf&quot;))
   if (window.external.isSubscribed("http://test.microsoft.com/tst.cdf"))
     alert (&quot;You are subscribed!&quot;);
     alert ("You are subscribed!");
   else
   else
     alert (&quot;You are NOT subscribed!&quot;);
     alert ("You are NOT subscribed!");
</SCRIPT&gt;
</SCRIPT>
                 </pre>
                 </pre>
Cross-frame security rules apply to this script call. Script in a document can only check to see if the user is subscribed to sites on the same domain.
Cross-frame security rules apply to this script call. Script in a document can only check to see if the user is subscribed to sites on the same domain.

Latest revision as of 12:30, 21 July 2020

Article ID: 175504

Article Last Modified on 7/1/2004



APPLIES TO

  • Microsoft Internet Explorer 4.0 128-Bit Edition
  • Microsoft Internet Explorer 4.01 Service Pack 2
  • Microsoft Internet Explorer 5.0
  • Microsoft Internet Explorer 5.5



This article was previously published under Q175504

SUMMARY

With the introduction of Active Channels in Internet Explorer 4.0, it may be desirable to determine whether a user is already subscribed to a channel, so that a Web page or an application does not redundantly offer users the ability to subscribe to a channel they've already subscribed to.

MORE INFORMATION

This article describes how to check a subscription from C++, Visual Basic, and script.

C++ - using ISubscriptionMgr::IsSubscribed

The code below demonstrates how this can be done using C++, from a console application:

#include <windows.h>
#include <tchar.h>
#include <iostream.h>
#include <subsmgr.h>
#include <stdio.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;
      BSTR bstrURL =
        SysAllocString(L"http://test.microsoft.com/tst.cdf");
      hr = pSubscriptionMgr->IsSubscribed(bstrURL, &Bool);

      pSubscriptionMgr->Release();

      char szBuffer[250];
      TCHAR szURL[200];
      WideCharToMultiByte(CP_ACP, 0, bstrURL, -1, szURL, 200, NULL,
                          NULL);
      if (Bool)
          wsprintf (szBuffer,"YES, you are subscribed to %s\n",szURL);
      else
          wsprintf (szBuffer,"NOPE, you are NOT subscribed to %s\n",
                     szURL);
      cout << szBuffer;
      SysFreeString (bstrURL);
   }

   CoUninitialize();
}
                

Visual Basic - Using the ShellUIHelper Object

The code below demonstrates how this can be done in a standard Visual Basic application. To use the ShellUIHelper object, use Project->References to add a reference to "Microsoft Internet Controls."

Private Sub Form_Load()
    Dim ShlHlpr As ShellUIHelper

    Set ShlHlpr = New ShellUIHelper

    If ShlHlpr.IsSubscribed("http://test.microsoft.com/tst.cdf") Then
        MsgBox "You're Subscribed!"
    Else
        MsgBox "You're not Subscribed!"
    End If
End Sub
                

Please note that you must install the desktop update that comes with Internet Explorer 4.0x in order to use the ShellUIHelper object.

Script - Using window.external.isSubscribed

The code below demonstrates how this can be done, using JavaScript in an .htm page:

<SCRIPT>
  if (window.external.isSubscribed("http://test.microsoft.com/tst.cdf"))
     alert ("You are subscribed!");
  else
     alert ("You are NOT subscribed!");
</SCRIPT>
                

Cross-frame security rules apply to this script call. Script in a document can only check to see if the user is subscribed to sites on the same domain.

REFERENCES

Internet Client SDK documentation

Keywords: kbhowto kbchannels kbcode KB175504