c#,如何解决*.lnk文件标题?

发布于 2024-07-18 03:21:31 字数 800 浏览 6 评论 0 原文

我想获取快捷方式的标题,不是文件名,不是描述,而是标题。 如何得到它?

我已经学会从这里解析其目标路径,如何解析 .lnk c#

但我没有找到任何方法来获取其标题。


(来源:ggpht.com)


(来源:ggpht.com)

I want to get title of shortcut, not file name, not description, but title.
how to get it?

I have learn to resolve its target path from here, How to resolve a .lnk in c#

but i don't find any method to get its title.


(source: ggpht.com)


(source: ggpht.com)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

凉墨 2024-07-25 03:21:31

听起来您可能正在尝试获取链接指向的文件的标题,正如 JRL 所建议的那样。

如果您不想尝试这样做,我建议您在十六进制编辑器中打开这些.lnk文件之一,例如XVI32。 您也许可以从那里看出显示的中文名称是否嵌入在 .lnk 文件中或其他位置。

如果它在其他地方,它可能是扩展文件属性。 有一些源代码可能有助于检索该信息: 扩展文件属性

如果碰巧它位于 .lnk 文件内,我建议查看Windows 快捷方式规范 获取偏移量信息等有关该数据的位置。

It sounds like you might be trying to get the title of the file the link points to, as JRL suggests.

If you're not trying to do that, I'd recommend opening up one of these .lnk files in a hex editor like XVI32. You can probably tell from there whether the Chinese name displayed is embedded in the .lnk file or is somewhere else.

If it's somewhere else, it may be an Extended File Property. There's some source code that may help with retrieving that info: Extended File Properties

If by some chance it is inside the .lnk file, I recommend looking at the Windows Shortcut Specification to get offset information and such on the location of that data.

心如荒岛 2024-07-25 03:21:31

在快捷方式目录下有一个Desktop.ini隐藏文件,该文件记录了快捷方式的显示字符串信息。

Desktop.ini 文件示例:

 [LocalizedFileNames]
Windows Update.lnk=@%SystemRoot%\system32\wucltux.dll,-1
Default Programs.lnk=@%SystemRoot%\system32\sud.dll,-1

There is a Desktop.ini hidden file in shortcuts directory, the Desktop.ini file records display strings info of shortcuts.

Desktop.ini file sample:

 [LocalizedFileNames]
Windows Update.lnk=@%SystemRoot%\system32\wucltux.dll,-1
Default Programs.lnk=@%SystemRoot%\system32\sud.dll,-1
抽个烟儿 2024-07-25 03:21:31

您可以使用最新版本的代码包中的属性系统 API:(

系统中的所有 670 多个属性都可以使用简单的属性访问器访问)

http://code.msdn.microsoft.com/WindowsAPICodePack

我知道您当前需要的只是有限的lnk文件标题。 使用上述库,示例代码可能如下所示:

ShellLink myLink = ShellObject.FromParsingName("c:\somepath\myLink.lnk");

字符串标题 = myLink.Properties.System.Title.Value;

// 这就是它所指向的...
字符串目标 = myLink.Properties.System.TargetParsingPath.Value;

You can use the property system APIs in latest relase of Code pack:

(all the 670+ properties in the system are accesible using simple property accessors)

http://code.msdn.microsoft.com/WindowsAPICodePack

I know your current need is only limited title of lnk files. Using the above library, the sample code might look like:

ShellLink myLink = ShellObject.FromParsingName("c:\somepath\myLink.lnk");

string title = myLink.Properties.System.Title.Value;

// This is what its pointing to...
string target = myLink.Properties.System.TargetParsingPath.Value;

梦巷 2024-07-25 03:21:31

请定义“标题”。 唯一听起来相关的属性是快捷方式的文件名、目标的文件名和 .lnk 文件的描述数据。

Please define "title". The only attributes that sound relevent are the shortcut's file name, the target's file name, and the .lnk file's description data.

最后的乘客 2024-07-25 03:21:31

假设您指的是链接指向的文件的标题,而不是链接本身,并且您正在谈论 Windows,那么它是通过 NTFS 中的一项功能(替代流)完成的。 您可以使用此 文章

Assuming you mean the title of the file the link points to, not the link itself, and that you are talking about Windows, then it's done via a feature in NTFS, alternative streams. You can access those streams using code in this article.

幼儿园老大 2024-07-25 03:21:31

环顾四周创建快捷方式,看起来有很多使用脚本对象的跳跃。 但我错过了什么吗? 如果您有快捷方式的路径,则名称应该与您在路径中找到的名称完全相同,而不是您必须查找的某些属性。

    Dim f As FileInfo = New FileInfo("C:\Name of shortcut.lnk")
    Dim title As String = f.Name.Replace(".lnk", String.Empty)

Looking around on creating shortcuts, looks like there's a lot of jumping through hoops with scripting objects. But am I missing something? If you have a path to the shortcut, the name should be exactly what you find in the path, not some attribute you have to look up.

    Dim f As FileInfo = New FileInfo("C:\Name of shortcut.lnk")
    Dim title As String = f.Name.Replace(".lnk", String.Empty)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文