private void InstallShortcut(String shortcutPath, String exePath) { IShellLinkW newShortcut = (IShellLinkW) new CShellLink(); // Create a shortcut to the exe newShortcut.SetPath(exePath); // Open the shortcut property store, set the AppUserModelId property IPropertyStore newShortcutProperties = (IPropertyStore)newShortcut; PropVariantHelper varAppId = new PropVariantHelper(); varAppId.SetValue(APP_ID); newShortcutProperties.SetValue(PROPERTYKEY.AppUserModel_ID, varAppId.Propvariant); PropVariantHelper varToastId = new PropVariantHelper(); varToastId.VarType = VarEnum.VT_CLSID; varToastId.SetValue(typeof(NotificationActivator).GUID); newShortcutProperties.SetValue(PROPERTYKEY.AppUserModel_ToastActivatorCLSID, varToastId.Propvariant); // Commit the shortcut to disk ShellHelpers.IPersistFile newShortcutSave = (ShellHelpers.IPersistFile)newShortcut; newShortcutSave.Save(shortcutPath, true); }
private void InstallShortcut(String shortcutPath, String exePath) { IShellLinkW newShortcut = (IShellLinkW)new CShellLink(); // Create a shortcut to the exe newShortcut.SetPath(exePath); // Open the shortcut property store, set the AppUserModelId property IPropertyStore newShortcutProperties = (IPropertyStore)newShortcut; PropVariantHelper varAppId = new PropVariantHelper(); varAppId.SetValue(APP_ID); newShortcutProperties.SetValue(PROPERTYKEY.AppUserModel_ID, varAppId.Propvariant); PropVariantHelper varToastId = new PropVariantHelper(); varToastId.VarType = VarEnum.VT_CLSID; varToastId.SetValue(typeof(NotificationActivator).GUID); newShortcutProperties.SetValue(PROPERTYKEY.AppUserModel_ToastActivatorCLSID, varToastId.Propvariant); // Commit the shortcut to disk ShellHelpers.IPersistFile newShortcutSave = (ShellHelpers.IPersistFile)newShortcut; newShortcutSave.Save(shortcutPath, true); }