Skip to main content
JADarnell
Inspiring
February 17, 2009
Question

IDCS4 Win - Getting a link path

  • February 17, 2009
  • 1 reply
  • 529 views
Hello all:<br /><br />In CS3 I used this code to get the image filename of a link:<br /><br />UIDRef linkRef = linksManager -> GetNthLinkUID(link);<br />InterfacePtr<IDataLink> dataLink(linkRef, IID_IDATALINK);<br />PMString *S = Datalink -> GetFullName();<br /><br />// do stuff with S and delete S<br />S = Datalink -> GetBaseName();<br /><br />IDataLink has been deprecated according to the porting guide. Since I could not find any reference anywhere to a cal to a GetFullName, I tried using it anyway since the header is still there. The code looks like this using the new method for retrieving a list of links:<br /><br />InterfacePtr<ILinkManager> linksManager(document, IID_ILINKMANAGER);<br /><br />LinkQuery Query; // I want all links so I leave this blank.<br /><br />// below is just a fancy name for std::vector<br />ILinkManager::QueryResult QueryResult; <br /><br />linksManager -> QueryLinks(Query, QueryResult);<br /><br />linkCount = QueryResult.size();<br /><br />// Work through the links and gather the info needed<br />for(link = 0; link < linkCount; link++)<br /><br />{<br /><br /> // This produces a linkref with a stored UID that makes sense.<br /> UIDRef linkRef = UIDRef(db, QueryResult[link]); <br /><br /> <br /> InterfacePtr<IDataLink> dataLink(linkRef, IID_IDATALINK); <br /> if (dataLink == nil) // evaluated as true<br /><br />Under CS4 what is the correct way to retrieve an image filename through a link?<br /><br />TIA!<br /><br />John
This topic has been closed for replies.

1 reply

JADarnell
JADarnellAuthor
Inspiring
February 18, 2009
I have found the solution. <br /><br />One must use this code to get a link manager:<br /><br />b InterfacePtr<ILinkManager> linksManager(document, IID_ILINKMANAGER);<br /><br />Then one sets up a query with the link manager like so:<br /><br />// The programmer can fill the LinkQuery with info that will make <br />// the actual query selective. Leaving it blank as I have done <br />// here, selects all the links<br /><br />b LinkQuery Query;<br /><br />b ILinkManager::QueryResult QueryResult;<br /><br />Then one performs the query<br /><br />b linksManager -> QueryLinks(Query, QueryResult);<br /><br />The QueryResult is a std::vector, so using the member functions available to std::vector, one obtains the uid and then does the following:<br /><br />b UIDRef linkRef = UIDRef(db, LinkUID);<br /><br />b InterfacePtr<ILink> ALink(linkRef, UseDefaultIID());<br /><br />b InterfacePtr<ILinkResource> resource(linksManager->QueryResourceByUID(ALink -> GetResource()));<br /><br />b PMString Path = resource -> GetLongName(); //gets full path<br /><br />Using IResourceLink::GetShortName will give the programmer just the name.<br /><br />R,<br />John