Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Diagnostics;
- using Microsoft.Win32;
- using IWshRuntimeLibrary;
- using System.IO;
- namespace Shortcut
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- GetInstalledApps();
- }
- public void GetInstalledApps()
- {
- string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
- using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
- {
- foreach (string skName in rk.GetSubKeyNames())
- {
- using (RegistryKey sk = rk.OpenSubKey(skName))
- {
- try
- {
- listBox1.Items.Add(sk.GetValue("DisplayName"));
- }
- catch (Exception ex)
- { }
- }
- }
- label1.Text = listBox1.Items.Count.ToString();
- }
- }
- private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- listBox1.SelectedItems.Clear();
- for(int i = listBox1.Items.Count - 1; i >= 0; i--)
- {
- if (listBox1.Items[i].ToString().ToLower().Contains(textBox1.Text.ToLower()))
- {
- listBox1.SetSelected(i, true);
- }
- }
- label3.Text = listBox1.SelectedItems.Count.ToString() + " items found";
- }
- private void button2_Click(object sender, EventArgs e)
- {
- CreateShortcut();
- MessageBox.Show("Shortcut created!", "Shortcut", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- private void CreateShortcut()
- {
- object shDesktop = (object)"Desktop";
- WshShell shell = new WshShell();
- string shortcutAddress = (string)shell.SpecialFolders.Item(ref shDesktop) + listBox1.SelectedItem.ToString();
- IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress);
- shortcut.Description = "New shortcut for a Notepad";
- shortcut.Hotkey = "Ctrl+Shift+N";
- shortcut.TargetPath = Environment.GetFolderPath(Environment.SpecialFolder.System) + @"\notepad.exe";
- shortcut.Save();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment