C# Verknüpfung erstellen/Verknüpfungsziel abrufen
Nov 10, 2016 pm 02:49 PMVerknüpfungen werden unter Win32 häufig verwendet. Nach der Installation einer bestimmten Software werden beispielsweise einige Verknüpfungen
in einem bestimmten Verzeichnis erstellt, sodass ich keine verwalteten Klassen in .NET Shortcuts gefunden habe operiert werden, dann
using System; using System.IO; using System.Runtime.InteropServices; class Program { static void Main(string[] args) { CreateShortCut( // 创建快捷方式 @"C:\Users\windo\Desktop\ican.lnk", @"%HOMEDRIVE%/Program Files\Internet Explorer\IEXPLORE.EXE", AppDomain.CurrentDomain.BaseDirectory, @"%HOMEDRIVE%/Program Files\Internet Explorer\IEXPLORE.EXE, 0", "CTRL+ALT+Z" ); } public static readonly Guid CLSID_WshShell = new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8"); public static string GetShortCutTarget(string lnk) // 取快捷方式目标 { if (lnk != null && File.Exists(lnk)) { dynamic objWshShell = null, objShortcut = null; try { objWshShell = Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_WshShell)); objShortcut = objWshShell.CreateShortcut(lnk); return objShortcut.TargetPath; } finally { Marshal.ReleaseComObject(objShortcut); Marshal.ReleaseComObject(objWshShell); } } return string.Empty; } public static bool CreateShortCut(string lnkFileName, string targetPath, string arguments, string remark, string workingDirectory, string iconLocation, string hotKey ) { if (lnkFileName != null && lnkFileName.Length > 0) { dynamic objWshShell = null, objShortcut = null; try { objWshShell = Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_WshShell)); objShortcut = objWshShell.CreateShortcut(lnkFileName); objShortcut.WindowStyle = 1; objShortcut.Hotkey = hotKey; // 热键 objShortcut.TargetPath = targetPath; // 目标文件 objShortcut.Arguments = arguments; // 参数 objShortcut.Description = remark; // 备注 objShortcut.WorkingDirectory = workingDirectory; // 起始位置 objShortcut.IconLocation = iconLocation; // 图标位置 objShortcut.Save(); return true; } finally { Marshal.ReleaseComObject(objShortcut); Marshal.ReleaseComObject(objWshShell); } } return false; } }

Hot-Tools-Tags

Heißer Artikel

Hot-Tools-Tags

Notepad++7.3.1
Einfach zu bedienender und kostenloser Code-Editor

SublimeText3 chinesische Version
Chinesische Version, sehr einfach zu bedienen

Senden Sie Studio 13.0.1
Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver CS6
Visuelle Webentwicklungstools

SublimeText3 Mac-Version
Codebearbeitungssoftware auf Gottesniveau (SublimeText3)

Heiße Themen

So fügen Sie C-Compiler der nächsten Ebene hinzu

Methode zum Kopieren von Code nach C -Sprachkompiler

C Sprache Online -Programmierwebsite C Sprachkompiler Offizielle Website Zusammenfassung

Was sind die Webversionen von C -Sprach Compilern?

Was sind die Alternativen zu Null in der C -Sprache

Welcher C -Sprachkompiler ist besser?

Ist Null in der modernen Programmierung in der C -Sprache noch wichtig?

C Sprachkompilierer -Installations -Tutorial (Computerversion)
