Determining URL from ActiveX Control

This is a simple technique to determine the URL of the web page in which the ActiveX control is hosted.


I had to develop ActiveX controls for web based applications. Some of these controls were manipulating the local resources. To disable malicious use of these control by others through scripting, I had to implement security check. I decided to implement a simple security scheme where I determine the url in which the control is hosted. If the url comes from our domain, I enabled its functionality.

I used GetMoniker method of IOleClientSite Interface.The IMoniker interface has GetDisplayName() method,
which returns a user-readable representation of the moniker.


 HRESULT hrResult	= S_FALSE;
 IOleClientSite *pClientSite = NULL;
 IMoniker* pMoniker	= NULL;
 LPOLESTR sDisplayName;

 // If using ATL to develop, use the m_spClientSite data
 // member of CComControl class.

 // If using MFC, use the following code: 
 // (member function of COleControl class 
 // - don't forget to call release)
 // pClientSite = GetClientSite();

 hrResult = m_spClientSite->GetMoniker(OLEGETMONIKER_TEMPFORUSER,
  hrResult = pMoniker->GetDisplayName(NULL,

 //TODO : relevant processing with sDisplayName and
 //free sDisplayName using SysFreeString()


  • can you send me a demo plz

    Posted by fask_annexe on 06/12/2004 09:31am

    hi i want this source for my project , can you send me a demo plzz

  • Good Idea !

    Posted by Legacy on 02/14/2004 12:00am

    Originally posted by:

    This one is a good idea !

    Soon, I am glad to present You sone results of my research on COM related information processing using Microsoft windows driven computers ...

    Remember that website ID: YAMAOKU.ORG

    Connect to ""; to access those results ...

  • GetClientSite is null why

    Posted by Legacy on 01/09/2004 12:00am

    Originally posted by: Sax

    void CActiDiagCtrl::OnButton1() 
    //MFC Control
    LPOLECLIENTSITE pClientSite = GetClientSite();
    AfxMessageBox("Not working");
    Why is this not working

    My control is in a web page. I click on my Page1.htm to open the file and I click button one of my activex and it is not working.

  • Is there other alternative way? Thanks.

    Posted by Legacy on 12/06/2003 12:00am

    Originally posted by: AL

    Is there other alternative way? Thanks.

  • does this work with Netscape on windows ?

    Posted by Legacy on 07/17/2003 12:00am

    Originally posted by: Hrishikesh Lele


    Nice article !

    Could you pls let me know if this works with Netscape on Windows ?


  • Cool work !

    Posted by Legacy on 07/16/2003 12:00am

    Originally posted by: Hrishikesh Lele

    Cool work !

  • Good Idea

    Posted by Legacy on 05/03/2003 12:00am

    Originally posted by:

    This is a good idea ...

  • bad work!

    Posted by Legacy on 09/18/2002 12:00am

    Originally posted by: waterwhu

    can not resolve all of problem!!!
    can you stop using flashget to get some bad files?

  • eqwe

    Posted by Legacy on 03/01/2002 12:00am

    Originally posted by: erwe


Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

  • Enterprises are increasingly looking to platform as a service (PaaS) to lower their costs and speed their time to market for new applications. Developing, deploying, and managing applications in the cloud eliminates the time and expense of managing a physical infrastructure to support them. PaaS offerings must deliver additional long-term benefits, such as a lower total cost of ownership (TCO), rapid scalability, and ease of integration, all while providing robust security and availability. This report …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date