Программное создание ярлыка
Подскажите каким образом можно в фрэймворке создать ярлык на программу или линк хотябы на ресурс дайте где написано, можно английский. (C#)
ага всё спасибо, я просто не по правильным словам гуглил))
если комуто надо будет, то работает алгоритм отсюда:
1. Add a reference to the Windows Scripting Host Object Model (1.0 currently) at C:\WINDOWS\System32\wshom.ocx using the Add Reference dialog Browse tab.
2. Add a
Код:
using IWshRuntimeLibrary;
line to the top of the source code where you need to creat the shortcut.
3. The following lines of code create a shortcut:
Код:
//You can use any special folder from the enumeration or any valid Path string.
string s = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
IWshShell wsh = new WshShellClass();
IWshShortcut shtct = (IWshShortcut)wsh.CreateShortcut(s + "\\Your Name.lnk");
shtct.WindowStyle = 1; //for default window, 3 for maximize, 7 for minimize
shtct.TargetPath = Application.ExecutablePath; //for me, or any valid Path string
shtct.IconLocation = "notepad.exe, 0"; //of any icon you find, including your own.
shtct.Save();
string s = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
IWshShell wsh = new WshShellClass();
IWshShortcut shtct = (IWshShortcut)wsh.CreateShortcut(s + "\\Your Name.lnk");
shtct.WindowStyle = 1; //for default window, 3 for maximize, 7 for minimize
shtct.TargetPath = Application.ExecutablePath; //for me, or any valid Path string
shtct.IconLocation = "notepad.exe, 0"; //of any icon you find, including your own.
shtct.Save();
You can also assign values for the Arguments, Description, FullName, Hotkey, RelativePath, and WorkingDirectory string properties as per the WshShorcut Object in the MSDN documentation.
Now wasn't that easier than using Interop Services to CoCreateInstance() the IShellLink and IPersist Interfaces through use of the class ID and interface ID's and Interop Marshalling?