Skip to content

Commit

Permalink
添加项目文件。
Browse files Browse the repository at this point in the history
  • Loading branch information
MIAIONE committed Jul 25, 2021
1 parent 79daa81 commit 571a17f
Show file tree
Hide file tree
Showing 21 changed files with 1,363 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ArgsHelper.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Public Class ArgsHelper
Public Shared Function GetCommandLine() As IConfigurationRoot
Dim commands As New ConsoleApplicationBase
Dim list_param As New List(Of String)
For Each everyparam As String In commands.CommandLineArgs
list_param.Add(everyparam)
Next
Dim builder As ConfigurationBuilder = New ConfigurationBuilder()
builder.AddCommandLine(list_param.ToArray)
GC.Collect()
Return builder.Build()
End Function
Public Shared Function GetParam(params As String) As String
Dim iconfig As IConfigurationRoot = GetCommandLine()
Return iconfig.Item(params)
End Function
End Class
26 changes: 26 additions & 0 deletions CMDHelper.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Public Class Dism
Public Shared Property UpdatePercent As String
Public Shared Function MidStrEx_New(sourse As String, startstr As String, endstr As String) As String
Dim rg As Regex = New Regex("(?<=(" & startstr & "))[.\s\S]*?(?=(" & endstr & "))", RegexOptions.Multiline Or RegexOptions.Singleline)
Return rg.Match(sourse).Value
End Function
Public Shared Sub Run(cmd As String)
Dim procs As New Process
procs.StartInfo.FileName = Environment.GetFolderPath(Environment.SpecialFolder.System) + "\dism.exe"
procs.StartInfo.Arguments = cmd
procs.StartInfo.UseShellExecute = False
procs.StartInfo.CreateNoWindow = True
procs.StartInfo.RedirectStandardOutput = True
procs.StartInfo.StandardOutputEncoding = Encoding.UTF8
procs.StartInfo.RedirectStandardError = False
AddHandler procs.OutputDataReceived, AddressOf Proc_OutputDataReceived
procs.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
procs.Start()
procs.BeginOutputReadLine()
End Sub
Private Shared Sub Proc_OutputDataReceived(sender As Object, e As DataReceivedEventArgs)
Dim Oristr As String = MidStrEx_New(e.Data, "[", "]")
Dim Percent As String = Regex.Replace(Oristr, "[^0-9]+", "")
UpdatePercent = Percent
End Sub
End Class
16 changes: 16 additions & 0 deletions ClearConst.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Public Class ClearConst
Public ReadOnly WINDOWS_ROOT_PATH As String = Environment.GetFolderPath(Environment.SpecialFolder.Windows)
Public ReadOnly DISM_CLEAR_UPDATE_IMAGE As String = "/Online /Cleanup-Image /StartComponentCleanup /ResetBase"
Public ReadOnly WINDOWS_BT_FILE As String = WINDOWS_ROOT_PATH + "\$WINDOWS.~BT\"
Public ReadOnly WINDOWS_WS_FILE As String = WINDOWS_ROOT_PATH + "\$WINDOWS.~WS\"
Public ReadOnly PREFETCH_FILE As String = WINDOWS_ROOT_PATH + "\Prefetch\"
Public ReadOnly INTERNET_CACHE_FILE As String = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) + "\"
Public ReadOnly APPDATA_ROAMING_TEMP As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\Temp\"
Public ReadOnly APPDATA_LOCAL_TEMP As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\Temp\"
Public ReadOnly SYSTEM_TMP As String = Environment.GetEnvironmentVariable("TMP", EnvironmentVariableTarget.Machine) + "\"
Public ReadOnly SYSTEM_TEMP As String = Environment.GetEnvironmentVariable("TEMP", EnvironmentVariableTarget.Machine) + "\"
Public ReadOnly SYSTEM_TMPDIR As String = Environment.GetEnvironmentVariable("TMPDIR", EnvironmentVariableTarget.Machine) + "\"
Public ReadOnly USER_TMP As String = Environment.GetEnvironmentVariable("TMP", EnvironmentVariableTarget.User) + "\"
Public ReadOnly USER_TEMP As String = Environment.GetEnvironmentVariable("TEMP", EnvironmentVariableTarget.User) + "\"

End Class
77 changes: 77 additions & 0 deletions ClearHelper.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

Public Class ClearHelper
Public Shared Sub ClearMemory()
On Error Resume Next
Task.Factory.StartNew(New Action(Sub()

GC.Collect()
GC.WaitForPendingFinalizers()
Dim processes As Process() = Process.GetProcesses()
For Each oprocess As Process In processes
Try
If oprocess IsNot Process.GetCurrentProcess Then
If oprocess.Handle <> IntPtr.Zero Then
Psapi.EmptyWorkingSet(New Kernel32.SafeObjectHandle(oprocess.Handle))
End If
End If
Catch ex As SEHException
Catch ex As NullReferenceException
Catch ex As Exception
End Try
Next
End Sub))
End Sub
Public Shared Function GetCurrentMemoryUsing() As Single
On Error Resume Next
Dim cpu As PerformanceCounter = New PerformanceCounter("Memory", "Available MBytes", "")
Dim CPUs As Single = cpu.NextValue()
Dim Be_RAM As Single = (8089 - CPUs) / 8089 * 100
Return Be_RAM
End Function
Public Shared Sub ClearSystemProcess()
If My.Settings.ClearTask_Dwm Then
RestartProcess("dwm", False)
End If
If My.Settings.ClearTask_Explorer Then
RestartProcess("explorer")
End If
If My.Settings.ClearTask_SearchIndexer Then
RestartProcess("searchindexer", False)
End If
End Sub
Public Shared Sub RestartProcess(name As String, Optional autoRun As Boolean = True)
Dim ProcessPath As String
Dim process_all As Process() = Process.GetProcesses()
For Each every_proc As Process In process_all
If every_proc.ProcessName.ToLower = name Then
ProcessPath = every_proc.MainModule.FileName
every_proc.Kill()
If autoRun Then
Process.Start(ProcessPath)
End If
End If
Next
End Sub
Public Shared Sub ClearSystemUpdateTempFiles(dir As String)
On Error Resume Next
Task.Factory.StartNew(New Action(Sub()
DeleteDir(dir)
End Sub))
End Sub

Public Shared Sub DeleteDir(files As String)
On Error Resume Next
Dim fileInfo As DirectoryInfo = New DirectoryInfo(files) With {.Attributes = FileAttributes.Normal And FileAttributes.Directory}
File.SetAttributes(files, FileAttributes.Normal)
If Directory.Exists(files) Then
Parallel.ForEach(Directory.GetFileSystemEntries(files), New Action(Of String)(Sub(f)
If File.Exists(f) Then
File.Delete(f)
Else
DeleteDir(f)
End If
End Sub))
Directory.Delete(files)
End If
End Sub
End Class
20 changes: 20 additions & 0 deletions ConfigHelper.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Public Class ConfigHelper
Public Shared Sub SetAutoTime(time As Integer)
My.Settings.AutoClearTime = time
DymSaveAndReload()
End Sub

Public Shared Sub ReSet()
My.Settings.Reset()
End Sub
Public Shared Sub ReLoad()
My.Settings.Reload()
End Sub
Public Shared Sub Save()
My.Settings.Save()
End Sub
Public Shared Sub DymSaveAndReload()
Save()
ReLoad()
End Sub
End Class
25 changes: 25 additions & 0 deletions FastClear.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31005.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FastClear", "FastClear.vbproj", "{ED8A6495-1442-4FF2-88DC-4037736815D6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{ED8A6495-1442-4FF2-88DC-4037736815D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED8A6495-1442-4FF2-88DC-4037736815D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED8A6495-1442-4FF2-88DC-4037736815D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED8A6495-1442-4FF2-88DC-4037736815D6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8E2D29D8-62EE-41E4-8C47-6311C584BAFE}
EndGlobalSection
EndGlobal
196 changes: 196 additions & 0 deletions FastClear.vbproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{ED8A6495-1442-4FF2-88DC-4037736815D6}</ProjectGuid>
<OutputType>WinExe</OutputType>
<StartupObject>Sub Main</StartupObject>
<RootNamespace>FastClear</RootNamespace>
<AssemblyName>FastClear</AssemblyName>
<FileAlignment>512</FileAlignment>
<MyType>WindowsFormsWithCustomSubMain</MyType>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>FastClear.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DocumentationFile>FastClear.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<OptionExplicit>On</OptionExplicit>
</PropertyGroup>
<PropertyGroup>
<OptionCompare>Binary</OptionCompare>
</PropertyGroup>
<PropertyGroup>
<OptionStrict>Off</OptionStrict>
</PropertyGroup>
<PropertyGroup>
<OptionInfer>On</OptionInfer>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Extensions.Configuration, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Extensions.Configuration.5.0.0\lib\net461\Microsoft.Extensions.Configuration.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Configuration.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Extensions.Configuration.Abstractions.5.0.0\lib\net461\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Configuration.CommandLine, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Extensions.Configuration.CommandLine.5.0.0\lib\net461\Microsoft.Extensions.Configuration.CommandLine.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Extensions.Primitives.5.0.0\lib\net461\Microsoft.Extensions.Primitives.dll</HintPath>
</Reference>
<Reference Include="PInvoke.Kernel32, Version=0.7.0.0, Culture=neutral, PublicKeyToken=9e300f9f87f04a7a, processorArchitecture=MSIL">
<HintPath>packages\PInvoke.Kernel32.0.7.104\lib\net46\PInvoke.Kernel32.dll</HintPath>
</Reference>
<Reference Include="PInvoke.Psapi, Version=0.7.0.0, Culture=neutral, PublicKeyToken=9e300f9f87f04a7a, processorArchitecture=MSIL">
<HintPath>packages\PInvoke.Psapi.0.7.104\lib\net45\PInvoke.Psapi.dll</HintPath>
</Reference>
<Reference Include="PInvoke.Windows.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=9e300f9f87f04a7a, processorArchitecture=MSIL">
<HintPath>packages\PInvoke.Windows.Core.0.7.104\lib\net45\PInvoke.Windows.Core.dll</HintPath>
</Reference>
<Reference Include="SunnyUI, Version=3.0.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\SunnyUI.3.0.5\lib\net45\SunnyUI.dll</HintPath>
</Reference>
<Reference Include="SunnyUI.Common, Version=3.0.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\SunnyUI.Common.3.0.5\lib\net45\SunnyUI.Common.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Import Include="Microsoft.Extensions.Configuration" />
<Import Include="Microsoft.Extensions.Configuration.CommandLine" />
<Import Include="Microsoft.VisualBasic" />
<Import Include="Microsoft.VisualBasic.ApplicationServices" />
<Import Include="Microsoft.VisualBasic.CompilerServices" />
<Import Include="Microsoft.Win32" />
<Import Include="PInvoke" />
<Import Include="Sunny.UI" />
<Import Include="Sunny.UI.Win32" />
<Import Include="System" />
<Import Include="System.Collections" />
<Import Include="System.Collections.Generic" />
<Import Include="System.Configuration" />
<Import Include="System.Configuration.Install" />
<Import Include="System.Drawing" />
<Import Include="System.Diagnostics" />
<Import Include="System.IO" />
<Import Include="System.Reflection" />
<Import Include="System.Runtime.CompilerServices" />
<Import Include="System.Runtime.InteropServices" />
<Import Include="System.ServiceModel" />
<Import Include="System.ServiceProcess" />
<Import Include="System.Text" />
<Import Include="System.Text.RegularExpressions" />
<Import Include="System.Threading" />
<Import Include="System.Windows.Forms" />
<Import Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup>
<Compile Include="ArgsHelper.vb" />
<Compile Include="ClearConst.vb" />
<Compile Include="ClearHelper.vb" />
<Compile Include="CMDHelper.vb" />
<Compile Include="ConfigHelper.vb" />
<Compile Include="MainWindow.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainWindow.Designer.vb">
<DependentUpon>MainWindow.vb</DependentUpon>
<SubType>Form</SubType>
</Compile>
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Application.myapp</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="My Project\Resources.Designer.vb">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="My Project\Settings.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="Program.vb" />
<Compile Include="ServicesRun.vb" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="MainWindow.resx">
<DependentUpon>MainWindow.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
</None>
<None Include="My Project\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<CustomToolNamespace>My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
</Project>
Loading

0 comments on commit 571a17f

Please sign in to comment.