Можно создать дубликат:
How do you create an application shortcut (.lnk file) in C# or .NetПрименение ярлык
Привет,
Любой ключ о том, как создать ярлык для EXE-файл в C#?
Благодаря
Можно создать дубликат:
How do you create an application shortcut (.lnk file) in C# or .NetПрименение ярлык
Привет,
Любой ключ о том, как создать ярлык для EXE-файл в C#?
Благодаря
Я нашел этот ответ в Google, по адресу: http://www.geekpedia.com/tutorial125_Create-shortcuts-with-a-.NET-application.html
Just:
WshShell = new WshShellClass();
// Create the shortcut
IWshRuntimeLibrary.IWshShortcut MyShortcut;
// Choose the path for the shortcut
MyShortcut = IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(@"C:\MyShortcut.lnk");
// Where the shortcut should point to
MyShortcut.TargetPath = Application.ExecutablePath;
// Description for the shortcut
MyShortcut.Description = "Launch My Application";
// Location for the shortcut's icon
MyShortcut.IconLocation = Application.StartupPath + @"\app.ico";
// Create the shortcut at the given path
MyShortcut.Save();
Только не забудьте добавить ссылку на Windows Script Model Хост объект
Это тот же ответ, заданный в [дублированном вопросе] (http://stackoverflow.com/questions/234231/how-do-you-create-an-application-shortcut-lnk-file-in-c-or- сеть). –
@ Andy Это * не * тот же ответ, данный в дубликатном потоке. В другом потоке используется соответствующий API - объект COM ShellLink, который кто-то завернул в управляемую оболочку. –
@Ian: Возможно, мне следовало связать право [дублированный ответ] (http://stackoverflow.com/questions/234231/how-do-you-create-an-application-shortcut-lnk-file-in-c -или-нетто/234243 # 234243). Единственное отличие здесь в том, что код был вставлен с сайта. –
Вот мой Delphi код:
function CreateShellLink(const szFilename: string; const szDescription: string): IShellLinkA;
var
sl: IShellLinkA;
begin
sl := CreateComObject(CLSID_ShellLink) as IShellLinkA;
OleCheck(sl.SetPath(szFilename));
OleCheck(sl.SetDescription(szDescription));
Result := sl;
end;
Вам нужно будет выяснить, используя Win32 api из .NET.
Хотя это актуально, это вряд ли полезно для OP ... –
Ну, это немного полезно, это правильный способ сделать это. –
Правильный в соответствии с чем? –
Вы пробовали Google? http://www.google.com/search?q=c%23+create+shortcut, десятки результатов. –