views:

946

answers:

2

When an IE user clicks the link of a file residing in SharePoint (and user selects "read-only" access), the file is copied to Temporary Internet Files, my application is opened and passed that filename as a parameter. I'm trying to implement a "check out" button in my app so that a user can switch from read-only mode to check-out and edit mode. I haven't been able to find a way to learn the SharePoint URL for the file. On check-out and edit, it's no problem: there's a registry entry that maps the file on my system to the URL in SharePoint; I haven't found anything like that for read-only files.

EDIT: There is a URL column available in Windows Explorer, but when I display that column (in Explorer), all the values are blank. Also, I can't find any file information api call that will return this value for me.

UPDATE: I found some promising calls in the wininet.lib: FindFirstUrlCacheEntryEx (and "next") along with FindFirstUrlCacheGroup (and next). They didn't seem to return any data, and from what I read, these only return my application's use of the wininet api calls cache -- not I.E.'s.

I also tried running through the list of COM calls that IE made into my app when the file was opened to see what interfaces it was seeing if I supported. One that looked promising was the IMonikerProp interface, which, when I implemented it, did get called... however it only provided me with the mime type property, the classid of my app and the TrustedDownload flag.

A: 

Does the temporary file created have a good name (does it match what the file is actually called or is it gibberish). If it's a good name, you can probably search for it. Otherwise, without knowing the site, folder, filename, you might not be able to unless there is some additional data about the file somewhere.

s_hewitt
The name is decent, but I'll still have to cover the case of multiple files of the same name in several different SharePoint folders. Also, I won't know which SharePoint server to try in (in the case that there are more than 1).
Steve
Based on the user you might be able to narrow down the search to what server/files it is. Hopefully they dont have two files with the same name checked out at the same time.
s_hewitt
The case where the user checks out the file is already handled. There's registry entries that map that nicely. The case I am trying to handle is the case in which the user opens the file with no check-out, then wants to do a checkout within the app. MS Word does this (checkout button on toolbar)
Steve
+2  A: 

Maybe this site has the answer: How SharePoint communicates with Word via ActiveX

Another option could be to hook into the SharePoint ItemCheckingOut event. Example 1 Example 2 . In the event you could get the URL info and create some temporary file with the info or pass the info off to your program.

Link to ActiveX control info - Maybe this control is launched on everything? You might be able to tap into that.

s_hewitt
I have the checkout from SharePoint case handled; there are registry entries that map the local filename to the checkedout out URL under the HKEY_CURRENT_USER. I'm trying to handle the case of opening the file w/o checkout, then deciding to check the file out from within the app. MS Word does this
Steve
ItemCheckedOut and ItemCheckingOut are the only events I can find, they definitely arn't fired when an item is viewed as Read-Only? It feels like they must, because according to the link I just added, Word/Excel etc launch an ActiveX control to store this info.
s_hewitt