In Windows, you can grab a link from the address bar of a browser (Chrome, Firefox, Edge) and drop it on the desktop or in another folder and Windows will create a .URL file for it. This file contains the link and a reference to the cached icon for the page. The name of the file is the title of the page.
I need to replicate this capability in my own program. I'm using C++ and MFC. I have code using COleDropTarget that gets the url itself. I use RegisterClipboardFormat(_TEXT("UniformResourceLocator")) to catch this.
I could write code to go out to the link and parse the file for the <title>...
to get the page title, but I don't know how to get the path to the cached icon associated with the page. I would prefer not to download and create a new icon since there is already one in the icon cache.
I am thinking that there is some way the browsers make all this information available to explorer so it can create the .URL file, but I can't find any documentation on how this might happen. If anyone knows, please tell me. Ideally, a snippet of code that I can use to capture this info (url, page title, path to cached icon file and icon index if any) would be great. If there's a way to send a message to a browser to tell it to create a .URL file, that would also work.
Thank you so much!
What I have tried:
I have tried a class derived from COleDropTarget implementing OnDragOver, OnDragEnter, OnDragLeave and OnDrop. I have registered clipboard formats "UniformResourceLocator" and "UniformResourceLocatorW". I also tried clipboard format CF_TEXT, which seems to work, but others I tried did not catch a dropped url.