mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Fixed line endings and applied gitignore
This commit is contained in:
@ -1,109 +1,109 @@
|
||||
/*
|
||||
Copyright (C) 2011 Birunthan Mohanathas
|
||||
|
||||
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <TlHelp32.h>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include "../../Common/RawString.h"
|
||||
#include "../../Library/Export.h" // Rainmeter's exported functions
|
||||
|
||||
struct MeasureData
|
||||
{
|
||||
RawString processName;
|
||||
bool isRunning;
|
||||
|
||||
MeasureData() : isRunning(false) {}
|
||||
};
|
||||
|
||||
static UINT g_UpdateCount = 0;
|
||||
static std::vector<MeasureData*> g_Measures;
|
||||
|
||||
void CheckProcesses();
|
||||
|
||||
PLUGIN_EXPORT void Initialize(void** data, void* rm)
|
||||
{
|
||||
MeasureData* measure = new MeasureData;
|
||||
g_Measures.push_back(measure);
|
||||
|
||||
*data = measure;
|
||||
}
|
||||
|
||||
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
|
||||
{
|
||||
MeasureData* measure = (MeasureData*)data;
|
||||
|
||||
LPCWSTR value = RmReadString(rm, L"ProcessName", L"");
|
||||
measure->processName = value;
|
||||
}
|
||||
|
||||
PLUGIN_EXPORT double Update(void* data)
|
||||
{
|
||||
MeasureData* measure = (MeasureData*)data;
|
||||
|
||||
// Updates the measure only once per combined updates of all measures
|
||||
++g_UpdateCount;
|
||||
if (g_UpdateCount >= g_Measures.size())
|
||||
{
|
||||
CheckProcesses();
|
||||
g_UpdateCount = 0;
|
||||
}
|
||||
|
||||
return measure->isRunning ? 1.0 : -1.0;
|
||||
}
|
||||
|
||||
PLUGIN_EXPORT void Finalize(void* data)
|
||||
{
|
||||
MeasureData* measure = (MeasureData*)data;
|
||||
std::vector<MeasureData*>::iterator iter = std::find(g_Measures.begin(), g_Measures.end(), measure);
|
||||
g_Measures.erase(iter);
|
||||
|
||||
delete measure;
|
||||
}
|
||||
|
||||
void CheckProcesses()
|
||||
{
|
||||
// Set everything to false
|
||||
std::vector<MeasureData*>::iterator iter = g_Measures.begin();
|
||||
for ( ; iter != g_Measures.end(); ++iter)
|
||||
{
|
||||
(*iter)->isRunning = false;
|
||||
}
|
||||
|
||||
HANDLE thSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
if (thSnapshot != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
PROCESSENTRY32 processEntry = {sizeof(processEntry)};
|
||||
if (Process32First(thSnapshot, &processEntry))
|
||||
{
|
||||
do
|
||||
{
|
||||
for (MeasureData* data : g_Measures)
|
||||
{
|
||||
if (_wcsicmp(processEntry.szExeFile, data->processName.c_str()) == 0)
|
||||
{
|
||||
data->isRunning = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (Process32Next(thSnapshot, &processEntry));
|
||||
}
|
||||
|
||||
CloseHandle(thSnapshot);
|
||||
}
|
||||
}
|
||||
/*
|
||||
Copyright (C) 2011 Birunthan Mohanathas
|
||||
|
||||
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <TlHelp32.h>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include "../../Common/RawString.h"
|
||||
#include "../../Library/Export.h" // Rainmeter's exported functions
|
||||
|
||||
struct MeasureData
|
||||
{
|
||||
RawString processName;
|
||||
bool isRunning;
|
||||
|
||||
MeasureData() : isRunning(false) {}
|
||||
};
|
||||
|
||||
static UINT g_UpdateCount = 0;
|
||||
static std::vector<MeasureData*> g_Measures;
|
||||
|
||||
void CheckProcesses();
|
||||
|
||||
PLUGIN_EXPORT void Initialize(void** data, void* rm)
|
||||
{
|
||||
MeasureData* measure = new MeasureData;
|
||||
g_Measures.push_back(measure);
|
||||
|
||||
*data = measure;
|
||||
}
|
||||
|
||||
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
|
||||
{
|
||||
MeasureData* measure = (MeasureData*)data;
|
||||
|
||||
LPCWSTR value = RmReadString(rm, L"ProcessName", L"");
|
||||
measure->processName = value;
|
||||
}
|
||||
|
||||
PLUGIN_EXPORT double Update(void* data)
|
||||
{
|
||||
MeasureData* measure = (MeasureData*)data;
|
||||
|
||||
// Updates the measure only once per combined updates of all measures
|
||||
++g_UpdateCount;
|
||||
if (g_UpdateCount >= g_Measures.size())
|
||||
{
|
||||
CheckProcesses();
|
||||
g_UpdateCount = 0;
|
||||
}
|
||||
|
||||
return measure->isRunning ? 1.0 : -1.0;
|
||||
}
|
||||
|
||||
PLUGIN_EXPORT void Finalize(void* data)
|
||||
{
|
||||
MeasureData* measure = (MeasureData*)data;
|
||||
std::vector<MeasureData*>::iterator iter = std::find(g_Measures.begin(), g_Measures.end(), measure);
|
||||
g_Measures.erase(iter);
|
||||
|
||||
delete measure;
|
||||
}
|
||||
|
||||
void CheckProcesses()
|
||||
{
|
||||
// Set everything to false
|
||||
std::vector<MeasureData*>::iterator iter = g_Measures.begin();
|
||||
for ( ; iter != g_Measures.end(); ++iter)
|
||||
{
|
||||
(*iter)->isRunning = false;
|
||||
}
|
||||
|
||||
HANDLE thSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
if (thSnapshot != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
PROCESSENTRY32 processEntry = {sizeof(processEntry)};
|
||||
if (Process32First(thSnapshot, &processEntry))
|
||||
{
|
||||
do
|
||||
{
|
||||
for (MeasureData* data : g_Measures)
|
||||
{
|
||||
if (_wcsicmp(processEntry.szExeFile, data->processName.c_str()) == 0)
|
||||
{
|
||||
data->isRunning = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (Process32Next(thSnapshot, &processEntry));
|
||||
}
|
||||
|
||||
CloseHandle(thSnapshot);
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +1,40 @@
|
||||
#include <VerRsrc.h>
|
||||
#include "../../Version.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION PRODUCTVER
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE VFT_UNKNOWN
|
||||
{
|
||||
BLOCK "StringFileInfo"
|
||||
{
|
||||
BLOCK "040904E4"
|
||||
{
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
VALUE "LegalCopyright", "<22> 2011 - Birunthan Mohanathas"
|
||||
VALUE "ProductName", "Rainmeter"
|
||||
#ifdef _WIN64
|
||||
VALUE "ProductVersion", STRPRODUCTVER " (64-bit)"
|
||||
#else
|
||||
VALUE "ProductVersion", STRPRODUCTVER " (32-bit)"
|
||||
#endif //_WIN64
|
||||
}
|
||||
}
|
||||
BLOCK "VarFileInfo"
|
||||
{
|
||||
VALUE "Translation", 0x409, 1252
|
||||
}
|
||||
}
|
||||
#include <VerRsrc.h>
|
||||
#include "../../Version.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION PRODUCTVER
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE VFT_UNKNOWN
|
||||
{
|
||||
BLOCK "StringFileInfo"
|
||||
{
|
||||
BLOCK "040904E4"
|
||||
{
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
VALUE "LegalCopyright", "<22> 2011 - Birunthan Mohanathas"
|
||||
VALUE "ProductName", "Rainmeter"
|
||||
#ifdef _WIN64
|
||||
VALUE "ProductVersion", STRPRODUCTVER " (64-bit)"
|
||||
#else
|
||||
VALUE "ProductVersion", STRPRODUCTVER " (32-bit)"
|
||||
#endif //_WIN64
|
||||
}
|
||||
}
|
||||
BLOCK "VarFileInfo"
|
||||
{
|
||||
VALUE "Translation", 0x409, 1252
|
||||
}
|
||||
}
|
||||
|
@ -1,36 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.Default.props" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{05203741-CD80-4060-8218-EC5D1120FE3E}</ProjectGuid>
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<TargetName>Process</TargetName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.props" />
|
||||
<Import Project="$(SolutionDir)Build\VS\RainmeterPlugin.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>Psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="PluginProcess.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="PluginProcess.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.Default.props" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{05203741-CD80-4060-8218-EC5D1120FE3E}</ProjectGuid>
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<TargetName>Process</TargetName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.props" />
|
||||
<Import Project="$(SolutionDir)Build\VS\RainmeterPlugin.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>Psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="PluginProcess.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="PluginProcess.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
Reference in New Issue
Block a user