Skip to content

Commit

Permalink
Added installer
Browse files Browse the repository at this point in the history
  • Loading branch information
MattGHarvey committed May 17, 2020
1 parent 793e412 commit 694cbe1
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 71 deletions.
22 changes: 22 additions & 0 deletions ShortcutCleaner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,28 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
14 changes: 14 additions & 0 deletions ShortcutCleaner.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,30 @@ VisualStudioVersion = 16.0.30011.22
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShortcutCleaner", "ShortcutCleaner.csproj", "{0B8D5734-98A7-430D-A26D-A3E514C4938B}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "ShortcutCleaner Setup", "..\ShortcutCleaner Setup\ShortcutCleaner Setup.vdproj", "{38272DFC-2567-496D-B889-0EAFDCC33CF5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0B8D5734-98A7-430D-A26D-A3E514C4938B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B8D5734-98A7-430D-A26D-A3E514C4938B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B8D5734-98A7-430D-A26D-A3E514C4938B}.Debug|x64.ActiveCfg = Debug|x64
{0B8D5734-98A7-430D-A26D-A3E514C4938B}.Debug|x64.Build.0 = Debug|x64
{0B8D5734-98A7-430D-A26D-A3E514C4938B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B8D5734-98A7-430D-A26D-A3E514C4938B}.Release|Any CPU.Build.0 = Release|Any CPU
{0B8D5734-98A7-430D-A26D-A3E514C4938B}.Release|x64.ActiveCfg = Release|x64
{0B8D5734-98A7-430D-A26D-A3E514C4938B}.Release|x64.Build.0 = Release|x64
{38272DFC-2567-496D-B889-0EAFDCC33CF5}.Debug|Any CPU.ActiveCfg = Debug
{38272DFC-2567-496D-B889-0EAFDCC33CF5}.Debug|x64.ActiveCfg = Debug
{38272DFC-2567-496D-B889-0EAFDCC33CF5}.Debug|x64.Build.0 = Debug
{38272DFC-2567-496D-B889-0EAFDCC33CF5}.Release|Any CPU.ActiveCfg = Release
{38272DFC-2567-496D-B889-0EAFDCC33CF5}.Release|x64.ActiveCfg = Release
{38272DFC-2567-496D-B889-0EAFDCC33CF5}.Release|x64.Build.0 = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
51 changes: 36 additions & 15 deletions formMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

106 changes: 50 additions & 56 deletions formMain.cs
Original file line number Diff line number Diff line change
@@ -1,105 +1,89 @@
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.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using System.Diagnostics;

namespace ShortcutCleaner
{
public partial class formMain : Form
{
[DllImport("Shell32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);

public const int SHCNE_ASSOCCHANGED = 0x8000000;
public const int SHCNF_IDLIST = 0;
public string commonPath;
public string specialPath;

public formMain()
{
InitializeComponent();
this.WindowState = FormWindowState.Minimized;


}

private void formMain_Load(object sender, EventArgs e)
{
timer1.Interval = 7200000;
timer1.Start();
commonPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory);
specialPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
fileSystemWatcher1.Path = commonPath;
fileSystemWatcher2.Path = specialPath;
this.ShowInTaskbar = false;
clean();


loadClean(commonPath);
loadClean(specialPath);
}

private void timer1_Tick(object sender, EventArgs e)
{
// TODO: Insert monitoring activities here.
clean();

}
private void clean()

private void clean(string cleanPath)
{
// eventLog1.WriteEntry("Monitoring the System", EventLogEntryType.Information, eventId++);
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string checkEx = @".lnk";

foreach (string fileName in Directory.GetFiles(path))
string extension = Path.GetExtension(cleanPath);
if (extension == checkEx)
{
string extension = Path.GetExtension(fileName);
if (extension == checkEx)
{

File.Delete(fileName);




Thread.Sleep(2000);
File.Delete(cleanPath);
}

}
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero);
}

}
private void loadClean(string cleanPath)
{
string checkEx = @".lnk";

path = Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory);
foreach (string fileName in Directory.GetFiles(path))
foreach (string fileName in Directory.GetFiles(cleanPath))
{
string extension = Path.GetExtension(fileName);
if (extension == checkEx)
{

File.Delete(fileName);





}

}
}

private void bClean_Click(object sender, EventArgs e)
{
clean();
clean(commonPath);
clean(specialPath);
}

private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{




}

private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{

}

private void cleanNowToolStripMenuItem_Click(object sender, EventArgs e)
{
this.clean();

this.clean(specialPath);
this.clean(commonPath);
}

private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
Expand All @@ -111,13 +95,13 @@ private void aboutToolStripMenuItem_Click(object sender, EventArgs e)

private void TextBox1_TextChanged(object sender, EventArgs e)
{

}

private void lnkGitHub_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://github.com/MattGHarvey/ShortcutCleaner");
}

private void OnApplicationExit(object sender, EventArgs e)
{
//Cleanup so that the icon will be removed when the application is closed
Expand All @@ -126,19 +110,15 @@ private void OnApplicationExit(object sender, EventArgs e)

private void lnkGitHub_Resize(object sender, EventArgs e)
{

}

private void formMain_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{

notifyIcon1.Visible = true;
this.Hide();

}

}

private void formMain_FormClosing(object sender, FormClosingEventArgs e)
Expand All @@ -151,5 +131,19 @@ private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}

private void fileSystemWatcher1_Changed(object sender, FileSystemEventArgs e)
{
}

private void fileSystemWatcher1_Created(object sender, FileSystemEventArgs e)
{
clean(e.FullPath);
}

private void fileSystemWatcher2_Created(object sender, FileSystemEventArgs e)
{
clean(e.FullPath);
}
}
}
}
6 changes: 6 additions & 0 deletions formMain.resx
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,12 @@
CoVCoVAoFAqFQqFQKBQKhcIa/wYHeF1a5MC4kQAAAABJRU5ErkJggg==
</value>
</data>
<metadata name="fileSystemWatcher1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>501, 17</value>
</metadata>
<metadata name="fileSystemWatcher2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>724, 17</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAUAEBAAAAEAIABoBAAAVgAAABgYAAABACAAiAkAAL4EAAAgIAAAAQAgAKgQAABGDgAAMDAAAAEA
Expand Down

0 comments on commit 694cbe1

Please sign in to comment.