Parsing from a URL file

  • Thread starter Thread starter Steven Blair
  • Start date Start date
S

Steven Blair

Steven,

It looks like you are trying to get the shortcut from a URL shortcut
file. What you want to do is create an internet shortcut object through COM
interop, using the class id of CLSID_InternetShortcut (you should be able to
find this in one of the header files). Once you have that, you can cast
this instance to the IPersistFile interface, and call the Load method,
passing in the filename of the URL shortcut. Once you have that, you can
cast the shortcut instance to the IUniformResourceLocator interface, and
then call the GetURL method to get the shortcut.

Of course, this requires a whole lot of COM interop, but it is the right
way to do it (as the file format of a URL shortcut is not set in stone).
You could use the P/Invoke layer to call the INI functions to read the file
(as it is in that format), but I don't think that is a good idea,
personally.

Hope this helps.
 
Hello, Steven!

The way Nicholas offered seems to be smarter,
but if you only need that particular line, I would
suggest opening a URL file "manually" using
stream reader, and reading it line by line until
you reach "URL=..." or if it always the fourth line,
just "skip" right to it...
And then just extract the part of URL that you need.

Good luck.

You wrote on Mon, 22 Dec 2003 23:34:26 +0000 (UTC):

SB> I need to extract the URL from a url file. Here is an example

SB> [DEFAULT]
SB> BASEURL=http://www.gallifreyone.com/news.shtml
SB> [InternetShortcut]
SB> URL=http://www.gallifreyone.com/news.shtml#newsitemEpFllVZppFHWEgchmC
SB> Modified=8067017F439AC20107

SB> Can anyone give me some ideas on how to do this. I have trying various
SB> methods and its just not happening. The string I need is
SB> http://www.gallifreyone.com/news.shtml#newsitemEpFllVZppFHWEgchmC

SB> Any help on this would be appreciated.

With best regards, Nurchi BECHED.
 
Back
Top