如何以编程方式遵循.lnk文件 [英] How to follow a .lnk file programmatically

查看:185
本文介绍了如何以编程方式遵循.lnk文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个网络驱动器完全快捷方式(.LNK文件)指向的文件夹,我需要编程遍历他们在C#的WinForms应用程序。

We have a network drive full of shortcuts (.lnk files) that point to folders and I need to traverse them programmatically in a C# Winforms app.

什么的实际的选择我呢?

推荐答案

添加IWshRuntimeLibrary作为参考,您的项目。添加引用,COM选项卡,Windows脚本宿主对象模型。

Add IWshRuntimeLibrary as a reference to your project. Add Reference, COM tab, Windows Scripting Host Object Model.

下面是我如何得到一个快捷方式的属性:

Here is how I get the properties of a shortcut:

IWshRuntimeLibrary.IWshShell wsh = new IWshRuntimeLibrary.WshShellClass();
IWshRuntimeLibrary.IWshShortcut sc = (IWshRuntimeLibrary.IWshShortcut)wsh.CreateShortcut(filename);

快捷方式对象SC有TARGETPATH​​属性。

The shortcut object "sc" has a TargetPath property.

这篇关于如何以编程方式遵循.lnk文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆