/// <summary>
/// 获取整个文件夹中快捷方式
/// </summary>
/// <param name="path">文件夹路径</param>
private void GetShortcut(string path)
{
string driver = path.Substring(0, 2);
path
= path.Substring(2) + "\\"; //WQL中的文件夹前后都有"\"
path = path.Replace("\\", "\\\\"); //WQL中的文件夹分隔符应是"\\"

string wsql = "Select * From Win32_ShortcutFile Where Drive='" + driver + "' and Path='" + path + "'";
ManagementObjectSearcher searcher
= new ManagementObjectSearcher(wsql);
if (searcher == null) return;
foreach (ManagementObject o in searcher.Get())
{
listBox1.Items.Add(o.GetPropertyValue(
"Name").ToString() + " => " + o.GetPropertyValue("Target").ToString());
}
}

/// <summary>
/// 根据单一快捷方式获取
/// </summary>
/// <param name="path"></param>
/// <param name="filename"></param>
private void GetShortCutByLnk(string path,string filename)
{
string driver = path.Substring(0, 2);
path
= path.Substring(2) + "\\"; //WQL中的文件夹前后都有"\"
path = path.Replace("\\", "\\\\"); //WQL中的文件夹分隔符应是"\\"
string wsql = "Select * From Win32_ShortcutFile Where Drive='" + driver + "' and Path='" + path + "' and FileName ='" + filename + "'";

ManagementObjectSearcher searcher
= new ManagementObjectSearcher(wsql);
if (searcher == null) return;
foreach (ManagementObject o in searcher.Get())
{
listBox1.Items.Add(o.GetPropertyValue(
"Name").ToString() + " => " + o.GetPropertyValue("Target").ToString());
}
}

参考:

http://www.microsoft.com/china/technet/community/scriptcenter/resources/hey1208.mspx

http://www.yiminbaike.com

美国酝酿计分制移民政策

相关文章:

  • 2021-10-09
  • 2021-12-28
  • 2022-12-23
  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
猜你喜欢
  • 2022-12-23
  • 2021-09-12
  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
相关资源
相似解决方案