New plugin: RecycleManager

This commit is contained in:
Kimmo Pekkola 2009-03-08 17:03:08 +00:00
parent 0c792fbdbf
commit 6706010d1f
3 changed files with 403 additions and 0 deletions

View File

@ -0,0 +1,235 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="PluginRecycleManager"
ProjectGUID="{4F8C4C09-431C-45C4-830B-32006E783C3A}"
SccProjectName="PluginRecycleManager"
SccLocalPath=".">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release 64|Win32"
OutputDirectory=".\x64/Release"
IntermediateDirectory=".\x64/Release"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="1">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/GL /EHsc /Wp64 /GA "
Optimization="2"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;PluginRecycleManager_EXPORTS"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
PrecompiledHeaderFile=".\x64/Release/PluginRecycleManager.pch"
AssemblerListingLocation=".\x64/Release/"
ObjectFile=".\x64/Release/"
ProgramDataBaseFileName=".\x64/Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/machine:AMD64 /LTCG "
AdditionalDependencies="bufferoverflowU.lib odbc32.lib odbccp32.lib"
OutputFile="../../TestBench/x64/Release/Plugins/RecycleManager.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ProgramDatabaseFile=".\x64/Release/RecycleManager.pdb"
ImportLibrary=".\x64/Release/RecycleManager.lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\x64/Release/PluginRecycleManager.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1035"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\x32/Release"
IntermediateDirectory=".\x32/Release"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="1">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;PluginRecycleManager_EXPORTS"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\x32/Release/PluginRecycleManager.pch"
AssemblerListingLocation=".\x32/Release/"
ObjectFile=".\x32/Release/"
ProgramDataBaseFileName=".\x32/Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib odbccp32.lib"
OutputFile="../../TestBench/x32/Release/Plugins/RecycleManager.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ProgramDatabaseFile=".\x32/Release/RecycleManager.pdb"
ImportLibrary=".\x32/Release/RecycleManager.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\x32/Release/PluginRecycleManager.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1035"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\x32/Debug"
IntermediateDirectory=".\x32/Debug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="1">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;UNICODE;_USRDLL;PluginRecycleManager_EXPORTS"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\x32/Debug/PluginRecycleManager.pch"
AssemblerListingLocation=".\x32/Debug/"
ObjectFile=".\x32/Debug/"
ProgramDataBaseFileName=".\x32/Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib odbccp32.lib"
OutputFile="../../TestBench/x32/Debug/Plugins/RecycleManager.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\x32/Debug/RecycleManager.pdb"
ImportLibrary=".\x32/Debug/RecycleManager.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\x32/Debug/PluginRecycleManager.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1035"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="RecycleManager.cpp">
<FileConfiguration
Name="Release 64|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginRecycleManager_EXPORTS;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginRecycleManager_EXPORTS;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginRecycleManager_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,157 @@
/*
Copyright (C) 2005 Kimmo Pekkola, 2009 Greg Schoppe
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#pragma warning(disable: 4786)
#pragma warning(disable: 4996)
#include <windows.h>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <map>
#include <vector>
#include <time.h>
#include "..\..\Library\Export.h" // Rainmeter's exported functions
/* The exported functions */
extern "C"
{
__declspec( dllexport ) UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id);
__declspec( dllexport ) void Finalize(HMODULE instance, UINT id);
__declspec( dllexport ) double Update2(UINT id);
__declspec( dllexport ) UINT GetPluginVersion();
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
__declspec( dllexport ) void BinBang(LPCTSTR args, UINT id);
}
const int NUMRECYCLE = 1;
const int SIZERECYCLE = 2;
static std::map<UINT, int> g_Values;
/*
This function is called when the measure is initialized.
The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this
function are:
instance The instance of this DLL
iniFile The name of the ini-file (usually Rainmeter.ini)
section The name of the section in the ini-file for this measure
id The identifier for the measure. This is used to identify the measures that use the same plugin.
*/
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
{
int dataType = 0; // 1 for numRecycled, 2 for sizeRecycled
/* Read our own settings from the ini-file */
LPCTSTR type = ReadConfigString(section, L"RecycleType", L"COUNT");
if (type)
{
if (wcsicmp(L"COUNT", type) == 0)
{
dataType = NUMRECYCLE;
}
else if (wcsicmp(L"SIZE", type) == 0)
{
dataType = SIZERECYCLE;
}
else
{
std::wstring error = L"No such RecycleType: ";
error += type;
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK);
}
}
g_Values[id] = dataType;
return 0;
}
/*
This function is called when new value should be measured.
The function returns the new value.
*/
double Update2(UINT id)
{
int dataType = g_Values[id];
SHQUERYRBINFO RecycleBinInfo = { 0 };
RecycleBinInfo.cbSize = sizeof( RecycleBinInfo ); // Tell size of structure
SHQueryRecycleBin( L"C:", &RecycleBinInfo ); // Get recycle bin info
if (dataType == NUMRECYCLE)
{
return (double)RecycleBinInfo.i64Size; // size in bytes
}
else if (dataType == SIZERECYCLE)
{
return (double)RecycleBinInfo.i64NumItems; // number of items in bin
}
return 0;
}
/*
If the measure needs to free resources before quitting.
The plugin can export Finalize function, which is called
when Rainmeter quits (or refreshes).
*/
void Finalize(HMODULE instance, UINT id)
{
std::map<UINT, int>::iterator i1 = g_Values.find(id);
if (i1 != g_Values.end())
{
g_Values.erase(i1);
}
}
UINT GetPluginVersion()
{
return 1000;
}
LPCTSTR GetPluginAuthor()
{
return L"gschoppe (gschoppe@gmail.com)";
}
void BinBang(LPCTSTR args, UINT id)
{
std::wstring bang = args;
if (wcsicmp(bang.c_str(), L"EmptyBin") == 0)
{ //Empty the Recycle Bin
SHEmptyRecycleBin( NULL, NULL, NULL );
}
else
{
if (wcsicmp(bang.c_str(), L"EmptyBinSilent") == 0)
{ //Empty the Recycle Bin (no prompt)
SHEmptyRecycleBin( NULL, NULL,
SHERB_NOCONFIRMATION |
SHERB_NOPROGRESSUI |
SHERB_NOSOUND );
}
else
{ //Open the Recycle Bin folder
system("explorer.exe /N,::{645FF040-5081-101B-9F08-00AA002F954E}");
}
}
}

View File

@ -73,6 +73,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginWirelessInfo", "Plugi
{BE3325E4-475C-40D0-9745-EE20BA3D8443} = {BE3325E4-475C-40D0-9745-EE20BA3D8443} {BE3325E4-475C-40D0-9745-EE20BA3D8443} = {BE3325E4-475C-40D0-9745-EE20BA3D8443}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginRecycleManager", "Plugins\PluginRecycleManager\PluginRecycleManager.vcproj", "{4F8C4C09-431C-45C4-830B-32006E783C3A}"
ProjectSection(ProjectDependencies) = postProject
{BE3325E4-475C-40D0-9745-EE20BA3D8443} = {BE3325E4-475C-40D0-9745-EE20BA3D8443}
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfiguration) = preSolution GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug Debug = Debug
@ -170,6 +175,12 @@ Global
{F6803AC5-272F-402B-9CA0-DEF8A3D83D30}.Release.Build.0 = Release|Win32 {F6803AC5-272F-402B-9CA0-DEF8A3D83D30}.Release.Build.0 = Release|Win32
{F6803AC5-272F-402B-9CA0-DEF8A3D83D30}.Release 64.ActiveCfg = Release 64|Win32 {F6803AC5-272F-402B-9CA0-DEF8A3D83D30}.Release 64.ActiveCfg = Release 64|Win32
{F6803AC5-272F-402B-9CA0-DEF8A3D83D30}.Release 64.Build.0 = Release 64|Win32 {F6803AC5-272F-402B-9CA0-DEF8A3D83D30}.Release 64.Build.0 = Release 64|Win32
{4F8C4C09-431C-45C4-830B-32006E783C3A}.Debug.ActiveCfg = Debug|Win32
{4F8C4C09-431C-45C4-830B-32006E783C3A}.Debug.Build.0 = Debug|Win32
{4F8C4C09-431C-45C4-830B-32006E783C3A}.Release.ActiveCfg = Release|Win32
{4F8C4C09-431C-45C4-830B-32006E783C3A}.Release.Build.0 = Release|Win32
{4F8C4C09-431C-45C4-830B-32006E783C3A}.Release 64.ActiveCfg = Release 64|Win32
{4F8C4C09-431C-45C4-830B-32006E783C3A}.Release 64.Build.0 = Release 64|Win32
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection EndGlobalSection