Solved

Finding the path to the page that is calling my ATL ActiveX Control

Posted on 2006-06-12
3
355 Views
Last Modified: 2010-04-01
How do I find the URL to the file that is calling my ActiveX control.  I want to have <param>'s similar to flash which specify a file to download but I don't want the user to have to specify a full URL.

<object>
   <param name="swf" value="myflash.swf">
</object>

and then in my ActiveX control I initiate a download at:
http://www.example.com/sub/dir/myflash.swf
0
Comment
Question by:GENTP
3 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 16887498
If you're hosting at the same domain, you can use a path relative to the root, e.g.

<object>
   <param name="swf" value="/sub/dir/myflash.swf">
</object>
0
 
LVL 5

Author Comment

by:GENTP
ID: 16887562
I am, but I'm looking to find the path, server, and port info inside of the control.
0
 
LVL 2

Accepted Solution

by:
MechanTOurS earned 500 total points
ID: 16888114
LPSTR getBase()
{
   USES_CONVERSION; // for OLE2A

   LPMONIKER clientMoniker = NULL;
   
   if ( S_OK == m_spClientSite->GetMoniker(OLEGETMONIKER_ONLYIFTHERE,OLEWHICHMK_CONTAINER,&pClientMoniker) )
   {
      LPOLESTR oleClientBaseUrl = NULL;
      IBindCtx *pBindContext = NULL;
     
      if (CreateBindCtx( 0, &pBindContext ) == S_OK )
      {
         // resolve the path
         pClientMoniker->GetDisplayName( pBindContext, NULL, &oleClientBaseUrl );
         
         // convert it to LPSTR
         LPSTR clientBaseUrl = OLE2A(oleClientBaseUrl );
         
         // do whatever u want with it.
         // ......
         
         return clientBaseUrl;
      }
   }
}
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question