C#获取桌面快捷方式路径并读取其目标路径
主要核心:
1.查找桌面对应的路径
2.查找桌面路径下的所有快捷方式
3读取该快捷方式下对应的目标路径(程序启动的exe文件的路径)
(利用 com组件 Windows Script Host Object Model)
核心代码如下:
using IWshRuntimeLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace GetApplicationInstrallPath
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnReLoad_Click(object sender, EventArgs e)
{
string desktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);
//string deskpath2 = System.Environment.GetFolderPath(System.Environment.Spe