In C#,How To Get The Url of A ShortCut?

HappinessBoy 2008-06-18 07:01:35
First of all, say hello to everyone!
I encountered a problem that i want to get the truly url of a shotcut!~
Although I know how to create a shortcut,
but for access to its value -- the url, I can do nothing~
For example:On the desktop, there is a shortcut to point to http://community.csdn.net,
in that way,how can i get the value "http://community.csdn.net" by c# code?
tks~
...全文
134 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
HappinessBoy 2008-06-18
  • 打赏
  • 举报
回复
and HimeTale's answer is only applies to a website-shortcut~
In any case, thank you~all my friends!
HappinessBoy 2008-06-18
  • 打赏
  • 举报
回复
i found IWshURLShortcut to get the url of a website-shortcut,
and IWshShortcut to get the link of a application-shortcut

tks~~
HimeTale 2008-06-18
  • 打赏
  • 举报
回复
            StreamReader sr = new StreamReader(@"c:\ss.url");
string strContent = sr.ReadToEnd();
Match m = Regex.Match(strContent, @"(?<=[InternetShortcut].*?url=)[\S]*",RegexOptions.IgnoreCase|RegexOptions.Singleline);
if (m.Success)
MessageBox.Show(m.Value);
else
MessageBox.Show("not a Shortcut");
whoami333 2008-06-18
  • 打赏
  • 举报
回复
http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=48404

Hope it will be of help!
HappinessBoy 2008-06-18
  • 打赏
  • 举报
回复
Yes, the shortcut point to one website is very simple,
and i had tried to get its text,
but if the shorcut is pointed to an application,
the text is binary and it's difficult to control,
all the way,thank u very much~
liangchencf 2008-06-18
  • 打赏
  • 举报
回复
there is a shortcut to point to http://www.baidu.com,

and file data is

[DEFAULT]
BASEURL=http://www.baidu.com/
[InternetShortcut]
URL=http://www.baidu.com/
Modified=E0F3CDF233D1C8015F
IconFile=http://www.baidu.com/favicon.ico
IconIndex=1


you can get the information from it.

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧