mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Cosmetic changes to code.
This commit is contained in:
@ -52,9 +52,9 @@ static std::map<UINT, CPUMeasure*> g_CPUMeasures;
|
||||
void SplitName(WCHAR* names, std::vector< std::wstring >& splittedNames)
|
||||
{
|
||||
WCHAR* token;
|
||||
|
||||
|
||||
token = wcstok(names, L";");
|
||||
while(token != NULL)
|
||||
while (token != NULL)
|
||||
{
|
||||
splittedNames.push_back(token);
|
||||
token = wcstok(NULL, L";");
|
||||
@ -63,7 +63,7 @@ void SplitName(WCHAR* names, std::vector< std::wstring >& splittedNames)
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -110,7 +110,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
|
||||
bool CheckProcess(CPUMeasure* measure, const std::wstring& name)
|
||||
{
|
||||
if (measure->includes.empty())
|
||||
if (measure->includes.empty())
|
||||
{
|
||||
for (size_t i = 0; i < measure->excludes.size(); i++)
|
||||
{
|
||||
@ -141,7 +141,7 @@ bool CheckProcess(CPUMeasure* measure, const std::wstring& name)
|
||||
double Update2(UINT id)
|
||||
{
|
||||
static DWORD oldTime = 0;
|
||||
|
||||
|
||||
// Only update twice per second
|
||||
DWORD time = GetTickCount();
|
||||
if (oldTime == 0 || time - oldTime > 500)
|
||||
@ -153,25 +153,25 @@ double Update2(UINT id)
|
||||
LONGLONG newValue = 0;
|
||||
|
||||
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
|
||||
if(i != g_CPUMeasures.end())
|
||||
if (i != g_CPUMeasures.end())
|
||||
{
|
||||
CPUMeasure* measure = (*i).second;
|
||||
|
||||
if(measure)
|
||||
if (measure)
|
||||
{
|
||||
for (size_t i = 0; i < g_Processes.size(); i++)
|
||||
for (size_t i = 0; i < g_Processes.size(); i++)
|
||||
{
|
||||
// Check process include/exclude
|
||||
if (CheckProcess(measure, g_Processes[i].name))
|
||||
if (CheckProcess(measure, g_Processes[i].name))
|
||||
{
|
||||
if (g_Processes[i].oldValue != 0)
|
||||
if (g_Processes[i].oldValue != 0)
|
||||
{
|
||||
if (measure->topProcess == 0)
|
||||
if (measure->topProcess == 0)
|
||||
{
|
||||
// Add all values together
|
||||
newValue += g_Processes[i].newValue - g_Processes[i].oldValue;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// Find the top process
|
||||
if (newValue < g_Processes[i].newValue - g_Processes[i].oldValue)
|
||||
@ -197,14 +197,14 @@ double Update2(UINT id)
|
||||
//
|
||||
// // Then substract the excluded processes
|
||||
// std::vector< std::wstring >::iterator j = measure->excludes.begin();
|
||||
// for( ; j != measure->excludes.end(); j++)
|
||||
// for ( ; j != measure->excludes.end(); j++)
|
||||
// {
|
||||
// longvalue = GetPerfData(L"Process", (*j).c_str(), L"% Processor Time");
|
||||
// newValue += longvalue; // Adding means actually substraction
|
||||
// }
|
||||
//
|
||||
// // Compare with the old value
|
||||
// if(measure->oldValue != 0)
|
||||
// if (measure->oldValue != 0)
|
||||
// {
|
||||
// int val = 10000000 - (UINT)(newValue - measure->oldValue);
|
||||
// if (val < 0) val = 0;
|
||||
@ -216,14 +216,14 @@ double Update2(UINT id)
|
||||
// {
|
||||
// // Add the included processes
|
||||
// std::vector< std::wstring >::iterator j = measure->includes.begin();
|
||||
// for( ; j != measure->includes.end(); j++)
|
||||
// for ( ; j != measure->includes.end(); j++)
|
||||
// {
|
||||
// longvalue = GetPerfData(L"Process", (*j).c_str(), L"% Processor Time");
|
||||
// newValue += longvalue;
|
||||
// }
|
||||
//
|
||||
// // Compare with the old value
|
||||
// if(measure->oldValue != 0)
|
||||
// if (measure->oldValue != 0)
|
||||
// {
|
||||
// value = (UINT)(newValue - measure->oldValue);
|
||||
// }
|
||||
@ -241,14 +241,14 @@ double Update2(UINT id)
|
||||
This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
|
||||
if(i != g_CPUMeasures.end())
|
||||
if (i != g_CPUMeasures.end())
|
||||
{
|
||||
CPUMeasure* measure = (*i).second;
|
||||
|
||||
if (measure->topProcess == 2)
|
||||
if (measure->topProcess == 2)
|
||||
{
|
||||
return measure->topProcessName.c_str();
|
||||
}
|
||||
@ -266,7 +266,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
// delete the measure
|
||||
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
|
||||
if(i != g_CPUMeasures.end())
|
||||
if (i != g_CPUMeasures.end())
|
||||
{
|
||||
delete (*i).second;
|
||||
g_CPUMeasures.erase(i);
|
||||
@ -291,17 +291,17 @@ void UpdateProcesses()
|
||||
CPerfSnapshot snapshot(&g_CounterTitles);
|
||||
CPerfObjectList objList(&snapshot, &g_CounterTitles);
|
||||
|
||||
if(snapshot.TakeSnapshot(L"Process"))
|
||||
if (snapshot.TakeSnapshot(L"Process"))
|
||||
{
|
||||
pPerfObj = objList.GetPerfObject(L"Process");
|
||||
|
||||
if(pPerfObj)
|
||||
if (pPerfObj)
|
||||
{
|
||||
for(pObjInst = pPerfObj->GetFirstObjectInstance();
|
||||
for (pObjInst = pPerfObj->GetFirstObjectInstance();
|
||||
pObjInst != NULL;
|
||||
pObjInst = pPerfObj->GetNextObjectInstance())
|
||||
{
|
||||
if(pObjInst->GetObjectInstanceName(name, 256))
|
||||
if (pObjInst->GetObjectInstanceName(name, 256))
|
||||
{
|
||||
if (_wcsicmp(name, L"_Total") == 0)
|
||||
{
|
||||
@ -309,20 +309,20 @@ void UpdateProcesses()
|
||||
}
|
||||
|
||||
pPerfCntr = pObjInst->GetCounterByName(L"% Processor Time");
|
||||
if(pPerfCntr != NULL)
|
||||
if (pPerfCntr != NULL)
|
||||
{
|
||||
pPerfCntr->GetData(data, 256, NULL);
|
||||
|
||||
if(pPerfCntr->GetSize() == 8)
|
||||
|
||||
if (pPerfCntr->GetSize() == 8)
|
||||
{
|
||||
ProcessValues values;
|
||||
values.name = name;
|
||||
values.oldValue = 0;
|
||||
|
||||
// Check if we can find the old value
|
||||
for (size_t i = 0; i < g_Processes.size(); i++)
|
||||
for (size_t i = 0; i < g_Processes.size(); i++)
|
||||
{
|
||||
if (!g_Processes[i].found && g_Processes[i].name == name)
|
||||
if (!g_Processes[i].found && g_Processes[i].name == name)
|
||||
{
|
||||
values.oldValue = g_Processes[i].newValue;
|
||||
g_Processes[i].found = true;
|
||||
|
@ -61,7 +61,7 @@ float getHighestTemp();
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -73,10 +73,10 @@ float getHighestTemp();
|
||||
*/
|
||||
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
/*
|
||||
Read our own settings from the ini-file
|
||||
/*
|
||||
Read our own settings from the ini-file
|
||||
The ReadConfigString can be used for this purpose. Plugins
|
||||
can also read the config some other way (e.g. with
|
||||
can also read the config some other way (e.g. with
|
||||
GetPrivateProfileInt, but in that case the variables
|
||||
do not work.
|
||||
*/
|
||||
@ -100,7 +100,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -17,34 +17,34 @@ bool CSharedMemClient::ReadSharedMem(PCORE_TEMP_SHARED_DATA i_SharedData)
|
||||
HANDLE hdlMutex;
|
||||
|
||||
hdlMutex = CreateMutex(NULL,FALSE,CORE_TEMP_MUTEX_OBJECT);
|
||||
if (hdlMutex == NULL)
|
||||
{
|
||||
if (hdlMutex == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
WaitForSingleObject(hdlMutex, INFINITE);
|
||||
|
||||
}
|
||||
|
||||
WaitForSingleObject(hdlMutex, INFINITE);
|
||||
|
||||
hdlMemory = OpenFileMapping(
|
||||
FILE_MAP_READ, // Read only permission.
|
||||
TRUE,
|
||||
FILE_MAP_READ, // Read only permission.
|
||||
TRUE,
|
||||
CORE_TEMP_MAPPING_OBJECT); // "CoreTempMappingObject"
|
||||
|
||||
if (hdlMemory == NULL)
|
||||
{
|
||||
ReleaseMutex(hdlMutex);
|
||||
|
||||
if (hdlMemory == NULL)
|
||||
{
|
||||
ReleaseMutex(hdlMutex);
|
||||
CloseHandle(hdlMutex);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pSharedData = (PCORE_TEMP_SHARED_DATA)MapViewOfFile(hdlMemory, FILE_MAP_READ, 0, 0, 0);
|
||||
if (pSharedData == NULL)
|
||||
if (pSharedData == NULL)
|
||||
{
|
||||
CloseHandle(hdlMemory);
|
||||
hdlMemory = NULL;
|
||||
ReleaseMutex(hdlMutex);
|
||||
ReleaseMutex(hdlMutex);
|
||||
CloseHandle(hdlMutex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
__try
|
||||
{
|
||||
@ -59,7 +59,7 @@ bool CSharedMemClient::ReadSharedMem(PCORE_TEMP_SHARED_DATA i_SharedData)
|
||||
|
||||
UnmapViewOfFile(pSharedData);
|
||||
CloseHandle(hdlMemory);
|
||||
ReleaseMutex(hdlMutex);
|
||||
ReleaseMutex(hdlMutex);
|
||||
CloseHandle(hdlMutex);
|
||||
|
||||
return bRet;
|
||||
|
@ -97,7 +97,7 @@ static FolderInfo* GetFolderInfo(const wchar_t* aPath, const wchar_t* aIniPath)
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -139,7 +139,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
if (_wcsicmp(strIncludeSubFolders, L"1") == 0) {
|
||||
measureInfo->Folder->IncludeSubFolders(true);
|
||||
}
|
||||
|
||||
|
||||
const wchar_t* strShowHiddenFiles = ReadConfigString(section, L"IncludeHiddenFiles", L"");
|
||||
if (_wcsicmp(strShowHiddenFiles, L"1") == 0) {
|
||||
measureInfo->Folder->IncludeHiddenFiles(true);
|
||||
|
@ -19,119 +19,119 @@
|
||||
#include "makeptr.h"
|
||||
|
||||
CPerfObjectInstance::CPerfObjectInstance(
|
||||
PPERF_INSTANCE_DEFINITION const pPerfInstDef,
|
||||
PPERF_COUNTER_DEFINITION const pPerfCntrDef,
|
||||
DWORD nCounters, CPerfTitleDatabase * const pPerfCounterTitles,
|
||||
BOOL fDummy)
|
||||
PPERF_INSTANCE_DEFINITION const pPerfInstDef,
|
||||
PPERF_COUNTER_DEFINITION const pPerfCntrDef,
|
||||
DWORD nCounters, CPerfTitleDatabase * const pPerfCounterTitles,
|
||||
BOOL fDummy)
|
||||
{
|
||||
m_pPerfInstDef = pPerfInstDef;
|
||||
m_pPerfCntrDef = pPerfCntrDef;
|
||||
m_nCounters = nCounters;
|
||||
m_pPerfCounterTitles = pPerfCounterTitles;
|
||||
|
||||
m_fDummy = fDummy;
|
||||
m_pPerfInstDef = pPerfInstDef;
|
||||
m_pPerfCntrDef = pPerfCntrDef;
|
||||
m_nCounters = nCounters;
|
||||
m_pPerfCounterTitles = pPerfCounterTitles;
|
||||
|
||||
m_fDummy = fDummy;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfObjectInstance::GetObjectInstanceName(
|
||||
PTSTR pszObjInstName, DWORD nSize )
|
||||
PTSTR pszObjInstName, DWORD nSize )
|
||||
{
|
||||
if ( m_fDummy )
|
||||
{
|
||||
*pszObjInstName = 0; // Return an empty string
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( nSize < (m_pPerfInstDef->NameLength / sizeof(TCHAR)) )
|
||||
return FALSE;
|
||||
if ( m_fDummy )
|
||||
{
|
||||
*pszObjInstName = 0; // Return an empty string
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
PWSTR pszName = MakePtr(PWSTR, m_pPerfInstDef, m_pPerfInstDef->NameOffset);
|
||||
|
||||
#ifdef UNICODE
|
||||
lstrcpy( pszObjInstName, pszName );
|
||||
#else
|
||||
wcstombs( pszObjInstName, pszName, nSize );
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
if ( nSize < (m_pPerfInstDef->NameLength / sizeof(TCHAR)) )
|
||||
return FALSE;
|
||||
|
||||
PWSTR pszName = MakePtr(PWSTR, m_pPerfInstDef, m_pPerfInstDef->NameOffset);
|
||||
|
||||
#ifdef UNICODE
|
||||
lstrcpy( pszObjInstName, pszName );
|
||||
#else
|
||||
wcstombs( pszObjInstName, pszName, nSize );
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::MakeCounter( PPERF_COUNTER_DEFINITION const pCounterDef )
|
||||
{
|
||||
// Look up the name of this counter in the title database
|
||||
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
|
||||
pCounterDef->CounterNameTitleIndex );
|
||||
|
||||
DWORD nInstanceDefSize = m_fDummy ? 0 : m_pPerfInstDef->ByteLength;
|
||||
// Look up the name of this counter in the title database
|
||||
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
|
||||
pCounterDef->CounterNameTitleIndex );
|
||||
|
||||
// Create a new CPerfCounter. The caller is responsible for deleting it.
|
||||
return new CPerfCounter(pszName,
|
||||
pCounterDef->CounterType,
|
||||
MakePtr( PBYTE, m_pPerfInstDef,
|
||||
nInstanceDefSize +
|
||||
pCounterDef->CounterOffset ),
|
||||
pCounterDef->CounterSize );
|
||||
DWORD nInstanceDefSize = m_fDummy ? 0 : m_pPerfInstDef->ByteLength;
|
||||
|
||||
// Create a new CPerfCounter. The caller is responsible for deleting it.
|
||||
return new CPerfCounter(pszName,
|
||||
pCounterDef->CounterType,
|
||||
MakePtr( PBYTE, m_pPerfInstDef,
|
||||
nInstanceDefSize +
|
||||
pCounterDef->CounterOffset ),
|
||||
pCounterDef->CounterSize );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetCounterByIndex( DWORD index )
|
||||
{
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter;
|
||||
|
||||
if ( index >= m_nCounters )
|
||||
return 0;
|
||||
|
||||
pCurrentCounter = m_pPerfCntrDef;
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter;
|
||||
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping
|
||||
for ( DWORD i = 0; i < index; i++ )
|
||||
{
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
if ( index >= m_nCounters )
|
||||
return 0;
|
||||
|
||||
if ( pCurrentCounter->ByteLength == 0 )
|
||||
return 0;
|
||||
pCurrentCounter = m_pPerfCntrDef;
|
||||
|
||||
return MakeCounter( pCurrentCounter );
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping
|
||||
for ( DWORD i = 0; i < index; i++ )
|
||||
{
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
|
||||
if ( pCurrentCounter->ByteLength == 0 )
|
||||
return 0;
|
||||
|
||||
return MakeCounter( pCurrentCounter );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetFirstCounter( void )
|
||||
{
|
||||
m_currentCounter = 0;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
m_currentCounter = 0;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetNextCounter( void )
|
||||
{
|
||||
m_currentCounter++;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
m_currentCounter++;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetCounterByName( PCTSTR const pszName )
|
||||
{
|
||||
DWORD cntrIdx = m_pPerfCounterTitles->GetIndexFromTitleString(pszName);
|
||||
if ( cntrIdx == 0 )
|
||||
return 0;
|
||||
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter = m_pPerfCntrDef;
|
||||
DWORD cntrIdx = m_pPerfCounterTitles->GetIndexFromTitleString(pszName);
|
||||
if ( cntrIdx == 0 )
|
||||
return 0;
|
||||
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping and comparing
|
||||
for ( DWORD i = 0; i < m_nCounters; i++ )
|
||||
{
|
||||
if ( pCurrentCounter->CounterNameTitleIndex == cntrIdx )
|
||||
return MakeCounter( pCurrentCounter );
|
||||
|
||||
// Nope. Not this one. Advance to the next counter
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter = m_pPerfCntrDef;
|
||||
|
||||
return 0;
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping and comparing
|
||||
for ( DWORD i = 0; i < m_nCounters; i++ )
|
||||
{
|
||||
if ( pCurrentCounter->CounterNameTitleIndex == cntrIdx )
|
||||
return MakeCounter( pCurrentCounter );
|
||||
|
||||
// Nope. Not this one. Advance to the next counter
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -19,65 +19,65 @@
|
||||
#include "makeptr.h"
|
||||
|
||||
CPerfObjectList::CPerfObjectList(
|
||||
CPerfSnapshot * const pPerfSnapshot,
|
||||
CPerfTitleDatabase * const pPerfTitleDatabase )
|
||||
CPerfSnapshot * const pPerfSnapshot,
|
||||
CPerfTitleDatabase * const pPerfTitleDatabase )
|
||||
{
|
||||
m_pPerfSnapshot = pPerfSnapshot;
|
||||
m_pPerfCounterTitles = pPerfTitleDatabase;
|
||||
m_pPerfSnapshot = pPerfSnapshot;
|
||||
m_pPerfCounterTitles = pPerfTitleDatabase;
|
||||
}
|
||||
|
||||
CPerfObject *
|
||||
CPerfObjectList::GetFirstPerfObject( void )
|
||||
{
|
||||
m_currentObjectListIndex = 0;
|
||||
if ( m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
m_currentObjectListIndex = 0;
|
||||
if ( m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
|
||||
m_pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
m_pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
}
|
||||
|
||||
CPerfObject *
|
||||
CPerfObjectList::GetNextPerfObject( void )
|
||||
{
|
||||
// Are we at the last object in the list? Return NULL if so.
|
||||
if ( ++m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
// Are we at the last object in the list? Return NULL if so.
|
||||
if ( ++m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
|
||||
// Advance to the next PERF_OBJECT_TYPE structure
|
||||
m_pCurrObjectType = MakePtr(PPERF_OBJECT_TYPE,
|
||||
m_pCurrObjectType,
|
||||
m_pCurrObjectType->TotalByteLength );
|
||||
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
// Advance to the next PERF_OBJECT_TYPE structure
|
||||
m_pCurrObjectType = MakePtr(PPERF_OBJECT_TYPE,
|
||||
m_pCurrObjectType,
|
||||
m_pCurrObjectType->TotalByteLength );
|
||||
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
}
|
||||
|
||||
|
||||
CPerfObject *
|
||||
CPerfObjectList::GetPerfObject( PCTSTR const pszObjListName )
|
||||
{
|
||||
DWORD objListIdx
|
||||
= m_pPerfCounterTitles->GetIndexFromTitleString( pszObjListName );
|
||||
if ( 0 == objListIdx )
|
||||
return 0;
|
||||
DWORD objListIdx
|
||||
= m_pPerfCounterTitles->GetIndexFromTitleString( pszObjListName );
|
||||
if ( 0 == objListIdx )
|
||||
return 0;
|
||||
|
||||
// Point at first PERF_OBJECT_TYPE, and loop through the list, looking
|
||||
// for one that matches.
|
||||
PPERF_OBJECT_TYPE pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
// Point at first PERF_OBJECT_TYPE, and loop through the list, looking
|
||||
// for one that matches.
|
||||
PPERF_OBJECT_TYPE pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
|
||||
for ( unsigned i=0; i < m_pPerfSnapshot->GetNumObjectTypes(); i++ )
|
||||
{
|
||||
// Is this the one that matches?
|
||||
if ( pCurrObjectType->ObjectNameTitleIndex == objListIdx )
|
||||
return new CPerfObject(pCurrObjectType, m_pPerfCounterTitles);
|
||||
for ( unsigned i=0; i < m_pPerfSnapshot->GetNumObjectTypes(); i++ )
|
||||
{
|
||||
// Is this the one that matches?
|
||||
if ( pCurrObjectType->ObjectNameTitleIndex == objListIdx )
|
||||
return new CPerfObject(pCurrObjectType, m_pPerfCounterTitles);
|
||||
|
||||
// Nope... try the next object type
|
||||
pCurrObjectType = MakePtr( PPERF_OBJECT_TYPE,
|
||||
pCurrObjectType,
|
||||
pCurrObjectType->TotalByteLength );
|
||||
}
|
||||
|
||||
return 0;
|
||||
// Nope... try the next object type
|
||||
pCurrObjectType = MakePtr( PPERF_OBJECT_TYPE,
|
||||
pCurrObjectType,
|
||||
pCurrObjectType->TotalByteLength );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -19,105 +19,105 @@
|
||||
#include "perfcntr.h"
|
||||
|
||||
CPerfCounter::CPerfCounter( PTSTR const pszName, DWORD type,
|
||||
PBYTE const pData, DWORD cbData )
|
||||
PBYTE const pData, DWORD cbData )
|
||||
{
|
||||
m_pszName = _tcsdup( pszName );
|
||||
m_type = type;
|
||||
m_cbData = cbData;
|
||||
m_pData = new BYTE[m_cbData];
|
||||
memcpy( m_pData, pData, m_cbData );
|
||||
m_pszName = _tcsdup( pszName );
|
||||
m_type = type;
|
||||
m_cbData = cbData;
|
||||
m_pData = new BYTE[m_cbData];
|
||||
memcpy( m_pData, pData, m_cbData );
|
||||
}
|
||||
|
||||
CPerfCounter::~CPerfCounter( void )
|
||||
{
|
||||
free( m_pszName );
|
||||
delete []m_pData;
|
||||
free( m_pszName );
|
||||
delete []m_pData;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfCounter::GetData( PBYTE pBuffer, DWORD cbBuffer, DWORD *pType )
|
||||
{
|
||||
if ( cbBuffer < m_cbData ) // Make sure the buffer is big enough
|
||||
return FALSE;
|
||||
|
||||
memcpy( pBuffer, m_pData, m_cbData ); // copy the data
|
||||
if ( cbBuffer < m_cbData ) // Make sure the buffer is big enough
|
||||
return FALSE;
|
||||
|
||||
if ( pType ) // If the user wants the type, give it to them
|
||||
*pType = m_type;
|
||||
|
||||
return TRUE;
|
||||
memcpy( pBuffer, m_pData, m_cbData ); // copy the data
|
||||
|
||||
if ( pType ) // If the user wants the type, give it to them
|
||||
*pType = m_type;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
CPerfCounter::Format( PTSTR pszBuffer, DWORD nSize, BOOL fHex )
|
||||
{
|
||||
// Do better formatting!!! Check length!!!
|
||||
// Do better formatting!!! Check length!!!
|
||||
|
||||
PTSTR pszPrefix = TEXT("");
|
||||
TCHAR szTemp[512];
|
||||
|
||||
// First, ascertain the basic type (number, counter, text, or zero)
|
||||
switch ( m_type & 0x00000C00 )
|
||||
{
|
||||
case PERF_TYPE_ZERO:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("ZERO") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_TEXT:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("text counter") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_COUNTER:
|
||||
{
|
||||
switch( m_type & 0x00070000 )
|
||||
{
|
||||
case PERF_COUNTER_RATE:
|
||||
pszPrefix = TEXT("counter rate "); break;
|
||||
case PERF_COUNTER_FRACTION:
|
||||
pszPrefix = TEXT("counter fraction "); break;
|
||||
case PERF_COUNTER_BASE:
|
||||
pszPrefix = TEXT("counter base "); break;
|
||||
case PERF_COUNTER_ELAPSED:
|
||||
pszPrefix = TEXT("counter elapsed "); break;
|
||||
case PERF_COUNTER_QUEUELEN:
|
||||
pszPrefix = TEXT("counter queuelen "); break;
|
||||
case PERF_COUNTER_HISTOGRAM:
|
||||
pszPrefix = TEXT("counter histogram "); break;
|
||||
default:
|
||||
pszPrefix = TEXT("counter value "); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PTSTR pszFmt = fHex ? TEXT("%s%Xh") : TEXT("%s%u");
|
||||
|
||||
switch ( m_cbData )
|
||||
{
|
||||
case 1: wsprintf(szTemp, pszFmt, pszPrefix, *(PBYTE)m_pData);
|
||||
break;
|
||||
case 2: wsprintf(szTemp, pszFmt, pszPrefix, *(PWORD)m_pData);
|
||||
break;
|
||||
case 4: wsprintf(szTemp, pszFmt, pszPrefix, *(PDWORD)m_pData);
|
||||
break;
|
||||
case 8: // Danger! Assumes little-endian (X86) byte ordering
|
||||
wsprintf( szTemp, TEXT("%s%X%X"), pszPrefix,
|
||||
*(PDWORD)(m_pData+4), *(PDWORD)m_pData ); break;
|
||||
PTSTR pszPrefix = TEXT("");
|
||||
TCHAR szTemp[512];
|
||||
|
||||
// First, ascertain the basic type (number, counter, text, or zero)
|
||||
switch ( m_type & 0x00000C00 )
|
||||
{
|
||||
case PERF_TYPE_ZERO:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("ZERO") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_TEXT:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("text counter") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_COUNTER:
|
||||
{
|
||||
switch( m_type & 0x00070000 )
|
||||
{
|
||||
case PERF_COUNTER_RATE:
|
||||
pszPrefix = TEXT("counter rate "); break;
|
||||
case PERF_COUNTER_FRACTION:
|
||||
pszPrefix = TEXT("counter fraction "); break;
|
||||
case PERF_COUNTER_BASE:
|
||||
pszPrefix = TEXT("counter base "); break;
|
||||
case PERF_COUNTER_ELAPSED:
|
||||
pszPrefix = TEXT("counter elapsed "); break;
|
||||
case PERF_COUNTER_QUEUELEN:
|
||||
pszPrefix = TEXT("counter queuelen "); break;
|
||||
case PERF_COUNTER_HISTOGRAM:
|
||||
pszPrefix = TEXT("counter histogram "); break;
|
||||
default:
|
||||
pszPrefix = TEXT("counter value "); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PTSTR pszFmt = fHex ? TEXT("%s%Xh") : TEXT("%s%u");
|
||||
|
||||
switch ( m_cbData )
|
||||
{
|
||||
case 1: wsprintf(szTemp, pszFmt, pszPrefix, *(PBYTE)m_pData);
|
||||
break;
|
||||
case 2: wsprintf(szTemp, pszFmt, pszPrefix, *(PWORD)m_pData);
|
||||
break;
|
||||
case 4: wsprintf(szTemp, pszFmt, pszPrefix, *(PDWORD)m_pData);
|
||||
break;
|
||||
case 8: // Danger! Assumes little-endian (X86) byte ordering
|
||||
wsprintf( szTemp, TEXT("%s%X%X"), pszPrefix,
|
||||
*(PDWORD)(m_pData+4), *(PDWORD)m_pData ); break;
|
||||
break;
|
||||
|
||||
default: wsprintf( szTemp, TEXT("<unhandled size %u>"), m_cbData );
|
||||
}
|
||||
|
||||
switch ( m_type & 0x70000000 )
|
||||
{
|
||||
case PERF_DISPLAY_SECONDS:
|
||||
_tcscat( szTemp, TEXT(" secs") ); break;
|
||||
case PERF_DISPLAY_PERCENT:
|
||||
_tcscat( szTemp, TEXT(" %") ); break;
|
||||
case PERF_DISPLAY_PER_SEC:
|
||||
_tcscat( szTemp, TEXT(" /sec") ); break;
|
||||
}
|
||||
default: wsprintf( szTemp, TEXT("<unhandled size %u>"), m_cbData );
|
||||
}
|
||||
|
||||
lstrcpyn( pszBuffer, szTemp, nSize );
|
||||
|
||||
return TRUE;
|
||||
switch ( m_type & 0x70000000 )
|
||||
{
|
||||
case PERF_DISPLAY_SECONDS:
|
||||
_tcscat( szTemp, TEXT(" secs") ); break;
|
||||
case PERF_DISPLAY_PERCENT:
|
||||
_tcscat( szTemp, TEXT(" %") ); break;
|
||||
case PERF_DISPLAY_PER_SEC:
|
||||
_tcscat( szTemp, TEXT(" /sec") ); break;
|
||||
}
|
||||
|
||||
lstrcpyn( pszBuffer, szTemp, nSize );
|
||||
|
||||
return TRUE;
|
||||
}
|
@ -42,7 +42,7 @@ static std::map<UINT, PerfMeasure*> g_Measures;
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -105,21 +105,21 @@ double Update2(UINT id)
|
||||
double value = 0;
|
||||
|
||||
std::map<UINT, PerfMeasure*>::iterator i = g_Measures.find(id);
|
||||
if(i != g_Measures.end())
|
||||
if (i != g_Measures.end())
|
||||
{
|
||||
PerfMeasure* measure = (*i).second;
|
||||
|
||||
if(measure)
|
||||
if (measure)
|
||||
{
|
||||
ULONGLONG longvalue;
|
||||
longvalue = GetPerfData(measure->ObjectName.c_str(),
|
||||
measure->InstanceName.c_str(),
|
||||
longvalue = GetPerfData(measure->ObjectName.c_str(),
|
||||
measure->InstanceName.c_str(),
|
||||
measure->CounterName.c_str());
|
||||
|
||||
if(measure->Difference)
|
||||
if (measure->Difference)
|
||||
{
|
||||
// Compare with the old value
|
||||
if(!measure->FirstTime)
|
||||
if (!measure->FirstTime)
|
||||
{
|
||||
value = (double)(longvalue - measure->OldValue);
|
||||
}
|
||||
@ -145,7 +145,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
// delete the measure
|
||||
std::map<UINT, PerfMeasure*>::iterator i = g_Measures.find(id);
|
||||
if(i != g_Measures.end())
|
||||
if (i != g_Measures.end())
|
||||
{
|
||||
delete (*i).second;
|
||||
g_Measures.erase(i);
|
||||
@ -166,7 +166,7 @@ ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName
|
||||
WCHAR name[256];
|
||||
ULONGLONG value = 0;
|
||||
|
||||
if(ObjectName == NULL || CounterName == NULL || wcslen(ObjectName) == 0 || wcslen(CounterName) == 0)
|
||||
if (ObjectName == NULL || CounterName == NULL || wcslen(ObjectName) == 0 || wcslen(CounterName) == 0)
|
||||
{
|
||||
// Unable to continue
|
||||
return 0;
|
||||
@ -175,21 +175,21 @@ ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName
|
||||
CPerfSnapshot snapshot(&g_CounterTitles);
|
||||
CPerfObjectList objList(&snapshot, &g_CounterTitles);
|
||||
|
||||
if(snapshot.TakeSnapshot(ObjectName))
|
||||
if (snapshot.TakeSnapshot(ObjectName))
|
||||
{
|
||||
pPerfObj = objList.GetPerfObject(ObjectName);
|
||||
|
||||
if(pPerfObj)
|
||||
if (pPerfObj)
|
||||
{
|
||||
for(pObjInst = pPerfObj->GetFirstObjectInstance();
|
||||
for (pObjInst = pPerfObj->GetFirstObjectInstance();
|
||||
pObjInst != NULL;
|
||||
pObjInst = pPerfObj->GetNextObjectInstance())
|
||||
{
|
||||
if (InstanceName != NULL && wcslen(InstanceName) > 0)
|
||||
{
|
||||
if(pObjInst->GetObjectInstanceName(name, 256))
|
||||
if (pObjInst->GetObjectInstanceName(name, 256))
|
||||
{
|
||||
if(_wcsicmp(InstanceName, name) != 0)
|
||||
if (_wcsicmp(InstanceName, name) != 0)
|
||||
{
|
||||
delete pObjInst;
|
||||
continue;
|
||||
@ -203,23 +203,23 @@ ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName
|
||||
}
|
||||
|
||||
pPerfCntr = pObjInst->GetCounterByName(CounterName);
|
||||
if(pPerfCntr != NULL)
|
||||
if (pPerfCntr != NULL)
|
||||
{
|
||||
pPerfCntr->GetData(data, 256, NULL);
|
||||
|
||||
if(pPerfCntr->GetSize() == 1)
|
||||
|
||||
if (pPerfCntr->GetSize() == 1)
|
||||
{
|
||||
value = *(BYTE*)data;
|
||||
}
|
||||
else if(pPerfCntr->GetSize() == 2)
|
||||
}
|
||||
else if (pPerfCntr->GetSize() == 2)
|
||||
{
|
||||
value = *(WORD*)data;
|
||||
}
|
||||
else if(pPerfCntr->GetSize() == 4)
|
||||
else if (pPerfCntr->GetSize() == 4)
|
||||
{
|
||||
value = *(DWORD*)data;
|
||||
}
|
||||
else if(pPerfCntr->GetSize() == 8)
|
||||
else if (pPerfCntr->GetSize() == 8)
|
||||
{
|
||||
value = *(ULONGLONG*)data;
|
||||
}
|
||||
|
@ -19,78 +19,78 @@
|
||||
#include "makeptr.h"
|
||||
|
||||
CPerfObject::CPerfObject( PPERF_OBJECT_TYPE const pObjectList,
|
||||
CPerfTitleDatabase * const pPerfCounterTitles)
|
||||
CPerfTitleDatabase * const pPerfCounterTitles)
|
||||
{
|
||||
m_pObjectList = pObjectList;
|
||||
m_pPerfCounterTitles = pPerfCounterTitles;
|
||||
m_pObjectList = pObjectList;
|
||||
m_pPerfCounterTitles = pPerfCounterTitles;
|
||||
}
|
||||
|
||||
CPerfObjectInstance *
|
||||
CPerfObject::GetFirstObjectInstance( void )
|
||||
{
|
||||
m_currentObjectInstance = 0;
|
||||
if ( m_currentObjectInstance >= GetObjectInstanceCount() )
|
||||
return 0;
|
||||
m_currentObjectInstance = 0;
|
||||
if ( m_currentObjectInstance >= GetObjectInstanceCount() )
|
||||
return 0;
|
||||
|
||||
// Point at the first PERF_INSTANCE_DEFINITION
|
||||
m_pCurrentObjectInstanceDefinition =
|
||||
MakePtr( PPERF_INSTANCE_DEFINITION, m_pObjectList,
|
||||
m_pObjectList->DefinitionLength );
|
||||
// Point at the first PERF_INSTANCE_DEFINITION
|
||||
m_pCurrentObjectInstanceDefinition =
|
||||
MakePtr( PPERF_INSTANCE_DEFINITION, m_pObjectList,
|
||||
m_pObjectList->DefinitionLength );
|
||||
|
||||
return new CPerfObjectInstance(
|
||||
m_pCurrentObjectInstanceDefinition,
|
||||
MakePtr(PPERF_COUNTER_DEFINITION,
|
||||
m_pObjectList, m_pObjectList->HeaderLength),
|
||||
m_pObjectList->NumCounters,
|
||||
m_pPerfCounterTitles,
|
||||
m_pObjectList->NumInstances ==
|
||||
PERF_NO_INSTANCES ? TRUE : FALSE );
|
||||
return new CPerfObjectInstance(
|
||||
m_pCurrentObjectInstanceDefinition,
|
||||
MakePtr(PPERF_COUNTER_DEFINITION,
|
||||
m_pObjectList, m_pObjectList->HeaderLength),
|
||||
m_pObjectList->NumCounters,
|
||||
m_pPerfCounterTitles,
|
||||
m_pObjectList->NumInstances ==
|
||||
PERF_NO_INSTANCES ? TRUE : FALSE );
|
||||
}
|
||||
|
||||
CPerfObjectInstance *
|
||||
CPerfObject::GetNextObjectInstance( void )
|
||||
{
|
||||
if ( m_pObjectList->NumInstances == PERF_NO_INSTANCES )
|
||||
return 0;
|
||||
if ( m_pObjectList->NumInstances == PERF_NO_INSTANCES )
|
||||
return 0;
|
||||
|
||||
if ( ++m_currentObjectInstance >= GetObjectInstanceCount() )
|
||||
return 0;
|
||||
if ( ++m_currentObjectInstance >= GetObjectInstanceCount() )
|
||||
return 0;
|
||||
|
||||
// Advance to the next PERF_INSTANCE_DEFINITION in the list. However,
|
||||
// following the current PERF_INSTANCE_DEFINITION is the counter data,
|
||||
// which is also of variable length. So, we gotta take that into
|
||||
// account when finding the next PERF_INSTANCE_DEFINITION
|
||||
|
||||
// First, get a pointer to the counter data size field
|
||||
PDWORD pCounterDataSize
|
||||
= MakePtr(PDWORD, m_pCurrentObjectInstanceDefinition,
|
||||
m_pCurrentObjectInstanceDefinition->ByteLength);
|
||||
// Advance to the next PERF_INSTANCE_DEFINITION in the list. However,
|
||||
// following the current PERF_INSTANCE_DEFINITION is the counter data,
|
||||
// which is also of variable length. So, we gotta take that into
|
||||
// account when finding the next PERF_INSTANCE_DEFINITION
|
||||
|
||||
// Now we can point at the next PPERF_INSTANCE_DEFINITION
|
||||
m_pCurrentObjectInstanceDefinition = MakePtr(PPERF_INSTANCE_DEFINITION,
|
||||
m_pCurrentObjectInstanceDefinition,
|
||||
m_pCurrentObjectInstanceDefinition->ByteLength
|
||||
+ *pCounterDataSize);
|
||||
|
||||
// Create a CPerfObjectInstance based around the PPERF_INSTANCE_DEFINITION
|
||||
return new CPerfObjectInstance(m_pCurrentObjectInstanceDefinition,
|
||||
MakePtr(PPERF_COUNTER_DEFINITION,
|
||||
m_pObjectList,
|
||||
m_pObjectList->HeaderLength),
|
||||
m_pObjectList->NumCounters,
|
||||
m_pPerfCounterTitles,
|
||||
FALSE );
|
||||
// First, get a pointer to the counter data size field
|
||||
PDWORD pCounterDataSize
|
||||
= MakePtr(PDWORD, m_pCurrentObjectInstanceDefinition,
|
||||
m_pCurrentObjectInstanceDefinition->ByteLength);
|
||||
|
||||
// Now we can point at the next PPERF_INSTANCE_DEFINITION
|
||||
m_pCurrentObjectInstanceDefinition = MakePtr(PPERF_INSTANCE_DEFINITION,
|
||||
m_pCurrentObjectInstanceDefinition,
|
||||
m_pCurrentObjectInstanceDefinition->ByteLength
|
||||
+ *pCounterDataSize);
|
||||
|
||||
// Create a CPerfObjectInstance based around the PPERF_INSTANCE_DEFINITION
|
||||
return new CPerfObjectInstance(m_pCurrentObjectInstanceDefinition,
|
||||
MakePtr(PPERF_COUNTER_DEFINITION,
|
||||
m_pObjectList,
|
||||
m_pObjectList->HeaderLength),
|
||||
m_pObjectList->NumCounters,
|
||||
m_pPerfCounterTitles,
|
||||
FALSE );
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfObject::GetObjectTypeName( PTSTR pszObjTypeName, DWORD nSize )
|
||||
{
|
||||
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
|
||||
m_pObjectList->ObjectNameTitleIndex );
|
||||
|
||||
if ( !pszName )
|
||||
return FALSE;
|
||||
|
||||
lstrcpyn( pszObjTypeName, pszName, nSize );
|
||||
return TRUE;
|
||||
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
|
||||
m_pObjectList->ObjectNameTitleIndex );
|
||||
|
||||
if ( !pszName )
|
||||
return FALSE;
|
||||
|
||||
lstrcpyn( pszObjTypeName, pszName, nSize );
|
||||
return TRUE;
|
||||
}
|
@ -21,145 +21,145 @@ PBYTE CPerfSnapshot::c_pBuffer = NULL;
|
||||
DWORD CPerfSnapshot::c_cbBufferSize = 0;
|
||||
|
||||
CPerfSnapshot::CPerfSnapshot(
|
||||
CPerfTitleDatabase * pCounterTitles )
|
||||
CPerfTitleDatabase * pCounterTitles )
|
||||
{
|
||||
m_pPerfDataHeader = 0;
|
||||
m_pCounterTitles = pCounterTitles;
|
||||
m_pPerfDataHeader = 0;
|
||||
m_pCounterTitles = pCounterTitles;
|
||||
}
|
||||
|
||||
CPerfSnapshot::~CPerfSnapshot( void )
|
||||
{
|
||||
DisposeSnapshot();
|
||||
DisposeSnapshot();
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfSnapshot::TakeSnapshot( PCTSTR pszSnapshotItems )
|
||||
{
|
||||
DisposeSnapshot(); // Clear out any current snapshot
|
||||
DisposeSnapshot(); // Clear out any current snapshot
|
||||
|
||||
// Convert the input string (e.g., "Process") into the form required
|
||||
// by the HKEY_PERFORMANCE_DATA key (e.g., "232")
|
||||
// Convert the input string (e.g., "Process") into the form required
|
||||
// by the HKEY_PERFORMANCE_DATA key (e.g., "232")
|
||||
|
||||
TCHAR szConvertedItemNames[ 256 ];
|
||||
if ( !ConvertSnapshotItemName( pszSnapshotItems, szConvertedItemNames,
|
||||
sizeof(szConvertedItemNames) ) )
|
||||
return FALSE;
|
||||
TCHAR szConvertedItemNames[ 256 ];
|
||||
if ( !ConvertSnapshotItemName( pszSnapshotItems, szConvertedItemNames,
|
||||
sizeof(szConvertedItemNames) ) )
|
||||
return FALSE;
|
||||
|
||||
DWORD cbAllocSize = 0;
|
||||
LONG retValue;
|
||||
|
||||
while ( 1 ) // Loop until we get the data, or we fail unexpectedly
|
||||
{
|
||||
retValue = RegQueryValueEx( HKEY_PERFORMANCE_DATA,
|
||||
szConvertedItemNames, 0, 0,
|
||||
c_pBuffer, &c_cbBufferSize );
|
||||
DWORD cbAllocSize = 0;
|
||||
LONG retValue;
|
||||
|
||||
if ( retValue == ERROR_SUCCESS ) // We apparently got the snapshot
|
||||
{
|
||||
while ( 1 ) // Loop until we get the data, or we fail unexpectedly
|
||||
{
|
||||
retValue = RegQueryValueEx( HKEY_PERFORMANCE_DATA,
|
||||
szConvertedItemNames, 0, 0,
|
||||
c_pBuffer, &c_cbBufferSize );
|
||||
|
||||
if ( retValue == ERROR_SUCCESS ) // We apparently got the snapshot
|
||||
{
|
||||
m_pPerfDataHeader = (PPERF_DATA_BLOCK)c_pBuffer;
|
||||
|
||||
// Verify that the signature is a unicode "PERF"
|
||||
if ( memcmp( m_pPerfDataHeader->Signature, L"PERF", 8 ) )
|
||||
break;
|
||||
// Verify that the signature is a unicode "PERF"
|
||||
if ( memcmp( m_pPerfDataHeader->Signature, L"PERF", 8 ) )
|
||||
break;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else if ( retValue != ERROR_MORE_DATA ) // Anything other failure
|
||||
break; // code means something
|
||||
// bad happened, so bail out.
|
||||
return TRUE;
|
||||
}
|
||||
else if ( retValue != ERROR_MORE_DATA ) // Anything other failure
|
||||
break; // code means something
|
||||
// bad happened, so bail out.
|
||||
|
||||
// If we get here, our buffer wasn't big enough. Delete it and
|
||||
// try again with a bigger buffer.
|
||||
delete [] c_pBuffer;
|
||||
|
||||
// The new buffer size will be 4096 bytes bigger than the larger
|
||||
// of: 1) The previous allocation size, or 2) The size that the
|
||||
// RegQueryValueEx call said was necessary.
|
||||
if ( c_cbBufferSize > cbAllocSize )
|
||||
cbAllocSize = c_cbBufferSize + 4096;
|
||||
else
|
||||
cbAllocSize += 4096;
|
||||
// If we get here, our buffer wasn't big enough. Delete it and
|
||||
// try again with a bigger buffer.
|
||||
delete [] c_pBuffer;
|
||||
|
||||
// Allocate a new, larger buffer in preparation to try again.
|
||||
c_pBuffer = new BYTE[ cbAllocSize ];
|
||||
if ( !c_pBuffer )
|
||||
break;
|
||||
// The new buffer size will be 4096 bytes bigger than the larger
|
||||
// of: 1) The previous allocation size, or 2) The size that the
|
||||
// RegQueryValueEx call said was necessary.
|
||||
if ( c_cbBufferSize > cbAllocSize )
|
||||
cbAllocSize = c_cbBufferSize + 4096;
|
||||
else
|
||||
cbAllocSize += 4096;
|
||||
|
||||
c_cbBufferSize = cbAllocSize;
|
||||
}
|
||||
// Allocate a new, larger buffer in preparation to try again.
|
||||
c_pBuffer = new BYTE[ cbAllocSize ];
|
||||
if ( !c_pBuffer )
|
||||
break;
|
||||
|
||||
// If we get here, the RegQueryValueEx failed unexpectedly.
|
||||
return FALSE;
|
||||
c_cbBufferSize = cbAllocSize;
|
||||
}
|
||||
|
||||
// If we get here, the RegQueryValueEx failed unexpectedly.
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
CPerfSnapshot::DisposeSnapshot( void )
|
||||
{
|
||||
m_pPerfDataHeader = 0;
|
||||
m_pPerfDataHeader = 0;
|
||||
}
|
||||
|
||||
void
|
||||
CPerfSnapshot::CleanUp( void )
|
||||
{
|
||||
delete [] c_pBuffer;
|
||||
c_pBuffer = 0;
|
||||
delete [] c_pBuffer;
|
||||
c_pBuffer = 0;
|
||||
c_cbBufferSize = 0;
|
||||
}
|
||||
|
||||
DWORD
|
||||
CPerfSnapshot::GetNumObjectTypes( void )
|
||||
{
|
||||
return m_pPerfDataHeader ? m_pPerfDataHeader->NumObjectTypes: 0;
|
||||
return m_pPerfDataHeader ? m_pPerfDataHeader->NumObjectTypes: 0;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfSnapshot::GetSystemName( PTSTR pszSystemName, DWORD nSize )
|
||||
{
|
||||
if ( !m_pPerfDataHeader ) // If no snapshot data, bail out.
|
||||
return FALSE;
|
||||
if ( !m_pPerfDataHeader ) // If no snapshot data, bail out.
|
||||
return FALSE;
|
||||
|
||||
// Make sure the input buffer size is big enough
|
||||
if ( nSize < m_pPerfDataHeader->SystemNameLength )
|
||||
return FALSE;
|
||||
// Make sure the input buffer size is big enough
|
||||
if ( nSize < m_pPerfDataHeader->SystemNameLength )
|
||||
return FALSE;
|
||||
|
||||
// Make a unicode string point to the system name string
|
||||
// that's stored in the PERF_DATA_BLOCK
|
||||
LPWSTR lpwszName = MakePtr( LPWSTR, m_pPerfDataHeader,
|
||||
m_pPerfDataHeader->SystemNameOffset );
|
||||
// Make a unicode string point to the system name string
|
||||
// that's stored in the PERF_DATA_BLOCK
|
||||
LPWSTR lpwszName = MakePtr( LPWSTR, m_pPerfDataHeader,
|
||||
m_pPerfDataHeader->SystemNameOffset );
|
||||
|
||||
#ifdef UNICODE // Copy the PERF_DATA_BLOCK string to the input buffer
|
||||
lstrcpy( pszSystemName, lpwszName );
|
||||
#else
|
||||
wcstombs( pszSystemName, lpwszName, nSize );
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
#ifdef UNICODE // Copy the PERF_DATA_BLOCK string to the input buffer
|
||||
lstrcpy( pszSystemName, lpwszName );
|
||||
#else
|
||||
wcstombs( pszSystemName, lpwszName, nSize );
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PVOID
|
||||
CPerfSnapshot::GetPostHeaderPointer( void )
|
||||
{
|
||||
// Returns a header to the first byte following the PERF_DATA_BLOCK
|
||||
// (including the variable length system name string at the end)
|
||||
return m_pPerfDataHeader ?
|
||||
MakePtr(PVOID, m_pPerfDataHeader,m_pPerfDataHeader->HeaderLength)
|
||||
: 0;
|
||||
// Returns a header to the first byte following the PERF_DATA_BLOCK
|
||||
// (including the variable length system name string at the end)
|
||||
return m_pPerfDataHeader ?
|
||||
MakePtr(PVOID, m_pPerfDataHeader,m_pPerfDataHeader->HeaderLength)
|
||||
: 0;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfSnapshot::ConvertSnapshotItemName( PCTSTR pszIn,
|
||||
PTSTR pszOut, DWORD nSize )
|
||||
PTSTR pszOut, DWORD nSize )
|
||||
{
|
||||
if ( IsBadStringPtr( pszIn, 0xFFFFFFFF ) )
|
||||
return FALSE;
|
||||
if ( IsBadStringPtr( pszIn, 0xFFFFFFFF ) )
|
||||
return FALSE;
|
||||
|
||||
|
||||
DWORD objectID = m_pCounterTitles->GetIndexFromTitleString(pszIn);
|
||||
|
||||
if ( objectID )
|
||||
pszOut += wsprintf( pszOut, TEXT("%u "), objectID );
|
||||
else
|
||||
pszOut += wsprintf( pszOut, TEXT("%s "), pszIn );
|
||||
if ( objectID )
|
||||
pszOut += wsprintf( pszOut, TEXT("%u "), objectID );
|
||||
else
|
||||
pszOut += wsprintf( pszOut, TEXT("%s "), pszIn );
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
@ -16,143 +16,143 @@
|
||||
#include "Titledb.h"
|
||||
|
||||
CPerfTitleDatabase::CPerfTitleDatabase(
|
||||
PERFORMANCE_TITLE_TYPE titleType )
|
||||
PERFORMANCE_TITLE_TYPE titleType )
|
||||
{
|
||||
m_nLastIndex = 0;
|
||||
m_TitleStrings = 0;
|
||||
m_pszRawStrings = 0;
|
||||
m_nLastIndex = 0;
|
||||
m_TitleStrings = 0;
|
||||
m_pszRawStrings = 0;
|
||||
|
||||
// Determine the appropriate strings to pass to RegOpenKeyEx
|
||||
PTSTR psz009RegValue, pszLastIndexRegValue;
|
||||
if ( PERF_TITLE_COUNTER == titleType )
|
||||
{
|
||||
psz009RegValue = TEXT("Counter 009");
|
||||
pszLastIndexRegValue = TEXT("Last Counter");
|
||||
}
|
||||
else if ( PERF_TITLE_EXPLAIN == titleType )
|
||||
{
|
||||
psz009RegValue = TEXT("Explain 009");
|
||||
pszLastIndexRegValue = TEXT("Last Help");
|
||||
}
|
||||
else
|
||||
return;
|
||||
// Determine the appropriate strings to pass to RegOpenKeyEx
|
||||
PTSTR psz009RegValue, pszLastIndexRegValue;
|
||||
if ( PERF_TITLE_COUNTER == titleType )
|
||||
{
|
||||
psz009RegValue = TEXT("Counter 009");
|
||||
pszLastIndexRegValue = TEXT("Last Counter");
|
||||
}
|
||||
else if ( PERF_TITLE_EXPLAIN == titleType )
|
||||
{
|
||||
psz009RegValue = TEXT("Explain 009");
|
||||
pszLastIndexRegValue = TEXT("Last Help");
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
// Find out the max number of entries
|
||||
HKEY hKeyPerflib = 0;
|
||||
DWORD cbLastIndex;
|
||||
|
||||
// Open the registry key that has the values for the maximum number
|
||||
// of title strings
|
||||
if ( ERROR_SUCCESS != RegOpenKeyEx(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
TEXT("software\\microsoft\\windows nt\\currentversion\\perflib"),
|
||||
0, KEY_READ, &hKeyPerflib ) )
|
||||
return;
|
||||
// Find out the max number of entries
|
||||
HKEY hKeyPerflib = 0;
|
||||
DWORD cbLastIndex;
|
||||
|
||||
// Read in the number of title strings
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx(
|
||||
hKeyPerflib, pszLastIndexRegValue, 0, 0,
|
||||
(PBYTE)&m_nLastIndex, &cbLastIndex ) )
|
||||
{
|
||||
RegCloseKey( hKeyPerflib );
|
||||
return;
|
||||
}
|
||||
|
||||
RegCloseKey( hKeyPerflib );
|
||||
|
||||
//
|
||||
// Now go find and process the raw string data
|
||||
//
|
||||
// Open the registry key that has the values for the maximum number
|
||||
// of title strings
|
||||
if ( ERROR_SUCCESS != RegOpenKeyEx(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
TEXT("software\\microsoft\\windows nt\\currentversion\\perflib"),
|
||||
0, KEY_READ, &hKeyPerflib ) )
|
||||
return;
|
||||
|
||||
// Determine how big the raw data in the REG_MULTI_SZ value is
|
||||
DWORD cbTitleStrings;
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA, psz009RegValue, 0,0,0, &cbTitleStrings))
|
||||
return;
|
||||
// Read in the number of title strings
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx(
|
||||
hKeyPerflib, pszLastIndexRegValue, 0, 0,
|
||||
(PBYTE)&m_nLastIndex, &cbLastIndex ) )
|
||||
{
|
||||
RegCloseKey( hKeyPerflib );
|
||||
return;
|
||||
}
|
||||
|
||||
// Allocate memory for the raw registry title string data
|
||||
m_pszRawStrings = new TCHAR[cbTitleStrings];
|
||||
|
||||
// Read in the raw title strings
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA,
|
||||
psz009RegValue, 0, 0, (PBYTE)m_pszRawStrings,
|
||||
&cbTitleStrings ) )
|
||||
{
|
||||
delete []m_pszRawStrings;
|
||||
return;
|
||||
}
|
||||
RegCloseKey( hKeyPerflib );
|
||||
|
||||
// allocate memory for an array of string pointers.
|
||||
m_TitleStrings = new PTSTR[ m_nLastIndex+1 ];
|
||||
if ( !m_TitleStrings )
|
||||
{
|
||||
delete []m_pszRawStrings;
|
||||
return;
|
||||
}
|
||||
//
|
||||
// Now go find and process the raw string data
|
||||
//
|
||||
|
||||
// Initialize the m_TitleStrings to all NULLs, since there may
|
||||
// be some array slots that aren't used.
|
||||
memset( m_TitleStrings, 0, sizeof(PTSTR) * (m_nLastIndex+1) );
|
||||
// Determine how big the raw data in the REG_MULTI_SZ value is
|
||||
DWORD cbTitleStrings;
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA, psz009RegValue, 0,0,0, &cbTitleStrings))
|
||||
return;
|
||||
|
||||
// The raw data entries are an ASCII string index (e.g., "242"), followed
|
||||
// by the corresponding string. Fill in the appropriate slot in the
|
||||
// m_TitleStrings array with the pointer to the string name. The end
|
||||
// of the list is indicated by a double NULL.
|
||||
// Allocate memory for the raw registry title string data
|
||||
m_pszRawStrings = new TCHAR[cbTitleStrings];
|
||||
|
||||
PTSTR pszWorkStr = (PTSTR)m_pszRawStrings;
|
||||
unsigned cbCurrStr;
|
||||
// Read in the raw title strings
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA,
|
||||
psz009RegValue, 0, 0, (PBYTE)m_pszRawStrings,
|
||||
&cbTitleStrings ) )
|
||||
{
|
||||
delete []m_pszRawStrings;
|
||||
return;
|
||||
}
|
||||
|
||||
// While the length of the current string isn't 0...
|
||||
while ( 0 != (cbCurrStr = lstrlen( pszWorkStr)) )
|
||||
{
|
||||
// Convert the first string to a binary representation
|
||||
unsigned index = _ttoi( pszWorkStr ); // _ttoi -> atoi()
|
||||
// allocate memory for an array of string pointers.
|
||||
m_TitleStrings = new PTSTR[ m_nLastIndex+1 ];
|
||||
if ( !m_TitleStrings )
|
||||
{
|
||||
delete []m_pszRawStrings;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( index > m_nLastIndex )
|
||||
break;
|
||||
|
||||
// Now point to the string following it. This is the title string
|
||||
pszWorkStr += cbCurrStr + 1;
|
||||
// Initialize the m_TitleStrings to all NULLs, since there may
|
||||
// be some array slots that aren't used.
|
||||
memset( m_TitleStrings, 0, sizeof(PTSTR) * (m_nLastIndex+1) );
|
||||
|
||||
// Fill in the appropriate slot in the title strings array.
|
||||
m_TitleStrings[index] = pszWorkStr;
|
||||
|
||||
// Advance to the next index/title pair
|
||||
pszWorkStr += lstrlen(pszWorkStr) + 1;
|
||||
}
|
||||
// The raw data entries are an ASCII string index (e.g., "242"), followed
|
||||
// by the corresponding string. Fill in the appropriate slot in the
|
||||
// m_TitleStrings array with the pointer to the string name. The end
|
||||
// of the list is indicated by a double NULL.
|
||||
|
||||
PTSTR pszWorkStr = (PTSTR)m_pszRawStrings;
|
||||
unsigned cbCurrStr;
|
||||
|
||||
// While the length of the current string isn't 0...
|
||||
while ( 0 != (cbCurrStr = lstrlen( pszWorkStr)) )
|
||||
{
|
||||
// Convert the first string to a binary representation
|
||||
unsigned index = _ttoi( pszWorkStr ); // _ttoi -> atoi()
|
||||
|
||||
if ( index > m_nLastIndex )
|
||||
break;
|
||||
|
||||
// Now point to the string following it. This is the title string
|
||||
pszWorkStr += cbCurrStr + 1;
|
||||
|
||||
// Fill in the appropriate slot in the title strings array.
|
||||
m_TitleStrings[index] = pszWorkStr;
|
||||
|
||||
// Advance to the next index/title pair
|
||||
pszWorkStr += lstrlen(pszWorkStr) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
CPerfTitleDatabase::~CPerfTitleDatabase( )
|
||||
{
|
||||
delete []m_TitleStrings;
|
||||
m_TitleStrings = 0;
|
||||
delete []m_pszRawStrings;
|
||||
m_pszRawStrings = 0;
|
||||
m_nLastIndex = 0;
|
||||
delete []m_TitleStrings;
|
||||
m_TitleStrings = 0;
|
||||
delete []m_pszRawStrings;
|
||||
m_pszRawStrings = 0;
|
||||
m_nLastIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
PTSTR
|
||||
CPerfTitleDatabase::GetTitleStringFromIndex( unsigned index )
|
||||
{
|
||||
if ( index > m_nLastIndex ) // Is index within range?
|
||||
return 0;
|
||||
|
||||
return m_TitleStrings[ index ];
|
||||
if ( index > m_nLastIndex ) // Is index within range?
|
||||
return 0;
|
||||
|
||||
return m_TitleStrings[ index ];
|
||||
}
|
||||
|
||||
unsigned
|
||||
CPerfTitleDatabase::GetIndexFromTitleString( PCTSTR pszTitleString )
|
||||
{
|
||||
if ( IsBadStringPtr(pszTitleString, 0xFFFFFFFF) )
|
||||
return 0;
|
||||
if ( IsBadStringPtr(pszTitleString, 0xFFFFFFFF) )
|
||||
return 0;
|
||||
|
||||
// Loop through all the non-null string array entries, doing a case-
|
||||
// insensitive comparison. If found, return the correpsonding index
|
||||
for ( unsigned i = 1; i <= m_nLastIndex; i++ )
|
||||
{
|
||||
if ( m_TitleStrings[i] )
|
||||
if ( 0 == _tcsicmp( pszTitleString, m_TitleStrings[i] ) )
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
// Loop through all the non-null string array entries, doing a case-
|
||||
// insensitive comparison. If found, return the correpsonding index
|
||||
for ( unsigned i = 1; i <= m_nLastIndex; i++ )
|
||||
{
|
||||
if ( m_TitleStrings[i] )
|
||||
if ( 0 == _tcsicmp( pszTitleString, m_TitleStrings[i] ) )
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ typedef struct tagIPINFO
|
||||
typedef IPINFO* PIPINFO;
|
||||
|
||||
static std::map<UINT, pingData*> g_Values;
|
||||
static CRITICAL_SECTION g_CriticalSection;
|
||||
static CRITICAL_SECTION g_CriticalSection;
|
||||
static bool g_Initialized = false;
|
||||
static HINSTANCE g_ICMPInstance = NULL;
|
||||
|
||||
@ -99,7 +99,7 @@ std::string ConvertToAscii(LPCTSTR str)
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -127,7 +127,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
g_IcmpSendEcho = (IcmpSendEcho)GetProcAddress(g_ICMPInstance,"IcmpSendEcho");
|
||||
g_IcmpSendEcho2 = (IcmpSendEcho2)GetProcAddress(g_ICMPInstance,"IcmpSendEcho2");
|
||||
}
|
||||
|
||||
|
||||
g_Initialized = true;
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
if (pData->destAddr == INADDR_NONE)
|
||||
{
|
||||
WSADATA wsaData;
|
||||
if (WSAStartup(0x0101, &wsaData) == 0)
|
||||
if (WSAStartup(0x0101, &wsaData) == 0)
|
||||
{
|
||||
LPHOSTENT pHost;
|
||||
|
||||
@ -184,7 +184,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
pData->timeoutValue = wcstod(data, NULL);
|
||||
}
|
||||
|
||||
|
||||
if (valid)
|
||||
{
|
||||
g_Values[id] = pData;
|
||||
@ -210,10 +210,10 @@ DWORD WINAPI NetworkThreadProc(LPVOID pParam)
|
||||
DWORD res = g_IcmpSendEcho(
|
||||
hIcmpFile,
|
||||
pData->destAddr,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
reply,
|
||||
reply,
|
||||
replySize,
|
||||
pData->timeout);
|
||||
|
||||
@ -236,7 +236,7 @@ DWORD WINAPI NetworkThreadProc(LPVOID pParam)
|
||||
pData->threadHandle = 0;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
}
|
||||
return 0; // thread completed successfully
|
||||
return 0; // thread completed successfully
|
||||
}
|
||||
|
||||
/*
|
||||
@ -299,7 +299,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
}
|
||||
|
||||
// Last instance deletes the critical section
|
||||
if (g_Values.empty())
|
||||
if (g_Values.empty())
|
||||
{
|
||||
if (g_ICMPInstance)
|
||||
{
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include "../../Library/DisableThreadLibraryCalls.h" // contains DllMain entry point
|
||||
|
||||
typedef struct _PROCESSOR_POWER_INFORMATION
|
||||
typedef struct _PROCESSOR_POWER_INFORMATION
|
||||
{
|
||||
ULONG Number;
|
||||
ULONG MaxMhz;
|
||||
@ -69,7 +69,7 @@ FPCALLNTPOWERINFORMATION fpCallNtPowerInformation = NULL;
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -99,20 +99,20 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
|
||||
/* Read our own settings from the ini-file */
|
||||
LPCTSTR type = ReadConfigString(section, L"PowerState", L"");
|
||||
if(type)
|
||||
if (type)
|
||||
{
|
||||
if (_wcsicmp(L"ACLINE", type) == 0)
|
||||
{
|
||||
powerState = POWER_ACLINE;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"STATUS", type) == 0)
|
||||
{
|
||||
powerState = POWER_STATUS;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"STATUS2", type) == 0)
|
||||
{
|
||||
powerState = POWER_STATUS2;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"LIFETIME", type) == 0)
|
||||
{
|
||||
powerState= POWER_LIFETIME;
|
||||
@ -122,7 +122,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
g_Formats[id] = format;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"MHZ", type) == 0)
|
||||
{
|
||||
powerState= POWER_MHZ;
|
||||
@ -237,7 +237,7 @@ double Update2(UINT id)
|
||||
This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static WCHAR buffer[256];
|
||||
|
||||
|
@ -94,7 +94,7 @@ std::wstring ConvertToWide(LPCSTR str)
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -129,7 +129,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
|
||||
size_t start = 0;
|
||||
size_t pos = ext.find(L';');
|
||||
while (pos != std::wstring::npos)
|
||||
while (pos != std::wstring::npos)
|
||||
{
|
||||
qData.fileFilters.push_back(ext.substr(start, pos - start));
|
||||
start = pos + 1;
|
||||
@ -157,9 +157,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
}
|
||||
|
||||
if (PathIsDirectory(qData.pathname.c_str()))
|
||||
if (PathIsDirectory(qData.pathname.c_str()))
|
||||
{
|
||||
if (qData.pathname[qData.pathname.size() - 1] != L'\\')
|
||||
if (qData.pathname[qData.pathname.size() - 1] != L'\\')
|
||||
{
|
||||
qData.pathname += L"\\";
|
||||
}
|
||||
@ -168,7 +168,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
ScanFolder(qData, bSubfolders, qData.pathname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!qData.pathname.empty())
|
||||
{
|
||||
g_Values[id] = qData;
|
||||
@ -192,11 +192,11 @@ void ScanFolder(quoteData& qData, bool bSubfolders, const std::wstring& path)
|
||||
hSearch = FindFirstFile(searchPath.c_str(), &fileData);
|
||||
do
|
||||
{
|
||||
if(hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
|
||||
if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
if (bSubfolders)
|
||||
if (bSubfolders)
|
||||
{
|
||||
if (wcscmp(fileData.cFileName, L".") != 0 && wcscmp(fileData.cFileName, L"..") != 0)
|
||||
{
|
||||
@ -206,11 +206,11 @@ void ScanFolder(quoteData& qData, bool bSubfolders, const std::wstring& path)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!qData.fileFilters.empty())
|
||||
if (!qData.fileFilters.empty())
|
||||
{
|
||||
for (int i = 0; i < qData.fileFilters.size(); i++)
|
||||
for (int i = 0; i < qData.fileFilters.size(); i++)
|
||||
{
|
||||
if (!qData.fileFilters[i].empty() && PathMatchSpec(fileData.cFileName, qData.fileFilters[i].c_str()))
|
||||
if (!qData.fileFilters[i].empty() && PathMatchSpec(fileData.cFileName, qData.fileFilters[i].c_str()))
|
||||
{
|
||||
qData.files.push_back(path + fileData.cFileName);
|
||||
break;
|
||||
@ -223,7 +223,7 @@ void ScanFolder(quoteData& qData, bool bSubfolders, const std::wstring& path)
|
||||
}
|
||||
}
|
||||
}
|
||||
while(FindNextFile(hSearch, &fileData));
|
||||
while (FindNextFile(hSearch, &fileData));
|
||||
}
|
||||
|
||||
#define BUFFER_SIZE 4096
|
||||
@ -262,7 +262,7 @@ double Update2(UINT id)
|
||||
|
||||
qData.value.erase();
|
||||
|
||||
if (0xFEFF == *(WCHAR*)buffer)
|
||||
if (0xFEFF == *(WCHAR*)buffer)
|
||||
{
|
||||
// It's unicode
|
||||
WCHAR* wBuffer = (WCHAR*)buffer;
|
||||
@ -270,7 +270,7 @@ double Update2(UINT id)
|
||||
// Read until we find the first separator
|
||||
WCHAR* sepPos1 = NULL;
|
||||
WCHAR* sepPos2 = NULL;
|
||||
do
|
||||
do
|
||||
{
|
||||
size_t len = fread(buffer, sizeof(BYTE), BUFFER_SIZE, file);
|
||||
buffer[len] = 0;
|
||||
@ -299,7 +299,7 @@ double Update2(UINT id)
|
||||
while (sepPos1 == NULL);
|
||||
|
||||
// Find the second separator
|
||||
do
|
||||
do
|
||||
{
|
||||
sepPos2 = wcsstr(sepPos1, qData.separator.c_str());
|
||||
if (sepPos2 == NULL)
|
||||
@ -343,7 +343,7 @@ double Update2(UINT id)
|
||||
// Read until we find the first separator
|
||||
char* sepPos1 = NULL;
|
||||
char* sepPos2 = NULL;
|
||||
do
|
||||
do
|
||||
{
|
||||
size_t len = fread(buffer, sizeof(char), BUFFER_SIZE, file);
|
||||
aBuffer[len] = 0;
|
||||
@ -370,7 +370,7 @@ double Update2(UINT id)
|
||||
while (sepPos1 == NULL);
|
||||
|
||||
// Find the second separator
|
||||
do
|
||||
do
|
||||
{
|
||||
sepPos2 = strstr(sepPos1, ConvertToAscii(qData.separator.c_str()).c_str());
|
||||
if (sepPos2 == NULL)
|
||||
@ -419,11 +419,11 @@ double Update2(UINT id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
std::map<UINT, quoteData>::iterator i = g_Values.find(id);
|
||||
if (i != g_Values.end())
|
||||
|
@ -70,7 +70,7 @@ id The identifier for the measure. This is used to identify the measures
|
||||
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
MEASURETYPE dataType = NUMRECYCLE; // 1 for numRecycled, 2 for sizeRecycled
|
||||
|
||||
|
||||
/* Read our own settings from the ini-file */
|
||||
LPCTSTR type = ReadConfigString(section, L"RecycleType", L"COUNT");
|
||||
if (type)
|
||||
@ -78,11 +78,11 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
if (_wcsicmp(L"COUNT", type) == 0)
|
||||
{
|
||||
dataType = NUMRECYCLE;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"SIZE", type) == 0)
|
||||
{
|
||||
dataType = SIZERECYCLE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"RecycleType=";
|
||||
@ -93,9 +93,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
g_Values[id] = dataType;
|
||||
|
||||
|
||||
LPCTSTR drives = ReadConfigString(section, L"Drives", L"ALL");
|
||||
if (drives && wcslen(drives) > 0)
|
||||
{
|
||||
@ -105,7 +105,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
g_DriveList[id] = L"ALL";
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ void Tokenize(const std::wstring& str, std::vector<std::wstring>& tokens, const
|
||||
std::wstring::size_type lastPos = str.find_first_not_of(delimiters, 0);
|
||||
// Find first "non-delimiter".
|
||||
std::wstring::size_type pos = str.find_first_of(delimiters, lastPos);
|
||||
|
||||
|
||||
while (std::wstring::npos != pos || std::wstring::npos != lastPos)
|
||||
{
|
||||
// Found a token, add it to the vector.
|
||||
@ -136,13 +136,13 @@ double Update2(UINT id)
|
||||
{
|
||||
MEASURETYPE dataType = g_Values[id];
|
||||
std::wstring driveSet = g_DriveList[id];
|
||||
|
||||
SHQUERYRBINFO RecycleBinInfo = { 0 };
|
||||
RecycleBinInfo.cbSize = sizeof( RecycleBinInfo ); // Tell size of structure
|
||||
|
||||
if(_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
|
||||
SHQUERYRBINFO RecycleBinInfo = { 0 };
|
||||
RecycleBinInfo.cbSize = sizeof( RecycleBinInfo ); // Tell size of structure
|
||||
|
||||
if (_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
{
|
||||
if(SHQueryRecycleBin( NULL, &RecycleBinInfo ) == S_OK)
|
||||
if (SHQueryRecycleBin( NULL, &RecycleBinInfo ) == S_OK)
|
||||
{
|
||||
if (dataType == SIZERECYCLE)
|
||||
{
|
||||
@ -160,15 +160,15 @@ double Update2(UINT id)
|
||||
}
|
||||
}
|
||||
std::vector<std::wstring> tokens;
|
||||
std::wstring toSplit(driveSet.begin(), driveSet.end());
|
||||
std::wstring toSplit(driveSet.begin(), driveSet.end());
|
||||
double retVal = 0;
|
||||
Tokenize(toSplit, tokens, L"|");
|
||||
|
||||
for(int i=0;i < tokens.size(); i++)
|
||||
|
||||
for (int i=0;i < tokens.size(); i++)
|
||||
{
|
||||
double tempVal;
|
||||
std::wstring strd = tokens.at(i);
|
||||
SHQueryRecycleBin( strd.c_str(), &RecycleBinInfo ); // Get recycle bin info
|
||||
SHQueryRecycleBin( strd.c_str(), &RecycleBinInfo ); // Get recycle bin info
|
||||
if (dataType == SIZERECYCLE)
|
||||
{
|
||||
tempVal = (double)RecycleBinInfo.i64Size; // size in bytes
|
||||
@ -179,7 +179,7 @@ double Update2(UINT id)
|
||||
}
|
||||
retVal += tempVal;
|
||||
}
|
||||
|
||||
|
||||
return (retVal);
|
||||
}
|
||||
|
||||
@ -209,14 +209,14 @@ LPCTSTR GetPluginAuthor()
|
||||
|
||||
void ExecuteBang(LPCTSTR args, UINT id)
|
||||
{
|
||||
std::wstring bang = args;
|
||||
std::wstring bang = args;
|
||||
std::wstring driveSet = g_DriveList[id];
|
||||
|
||||
if (_wcsicmp(bang.c_str(), L"EmptyBin") == 0)
|
||||
{ //Empty the Recycle Bin
|
||||
if(_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
if (_wcsicmp(bang.c_str(), L"EmptyBin") == 0)
|
||||
{ //Empty the Recycle Bin
|
||||
if (_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
{
|
||||
if(SHEmptyRecycleBin( NULL, NULL, NULL ) == S_OK)
|
||||
if (SHEmptyRecycleBin( NULL, NULL, NULL ) == S_OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -226,23 +226,23 @@ void ExecuteBang(LPCTSTR args, UINT id)
|
||||
}
|
||||
}
|
||||
std::vector<std::wstring> tokens;
|
||||
std::wstring toSplit(driveSet.begin(), driveSet.end());
|
||||
std::wstring toSplit(driveSet.begin(), driveSet.end());
|
||||
Tokenize(toSplit, tokens, L"|");
|
||||
|
||||
for(int i=0;i < tokens.size(); i++)
|
||||
|
||||
for (int i=0;i < tokens.size(); i++)
|
||||
{
|
||||
std::wstring strd = tokens.at(i);
|
||||
SHEmptyRecycleBin( NULL, strd.c_str(), NULL ); // empty bin
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_wcsicmp(bang.c_str(), L"EmptyBinSilent") == 0)
|
||||
{ //Empty the Recycle Bin (no prompt)
|
||||
if(_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
{ //Empty the Recycle Bin (no prompt)
|
||||
if (_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
{
|
||||
if(SHEmptyRecycleBin( NULL, NULL, SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND ) == S_OK)
|
||||
if (SHEmptyRecycleBin( NULL, NULL, SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND ) == S_OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -252,24 +252,24 @@ void ExecuteBang(LPCTSTR args, UINT id)
|
||||
}
|
||||
}
|
||||
std::vector<std::wstring> tokens;
|
||||
std::wstring toSplit(driveSet.begin(), driveSet.end());
|
||||
std::wstring toSplit(driveSet.begin(), driveSet.end());
|
||||
Tokenize(toSplit, tokens, L"|");
|
||||
|
||||
for(int i=0;i < tokens.size(); i++)
|
||||
for (int i=0;i < tokens.size(); i++)
|
||||
{
|
||||
std::wstring strd = tokens.at(i);
|
||||
SHEmptyRecycleBin( NULL, strd.c_str(), SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND ); // empty bin
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (_wcsicmp(bang.c_str(), L"OpenBin") == 0)
|
||||
{ //Open the Recycle Bin folder
|
||||
//system("explorer.exe /N,::{645FF040-5081-101B-9F08-00AA002F954E}");
|
||||
}
|
||||
else if (_wcsicmp(bang.c_str(), L"OpenBin") == 0)
|
||||
{ //Open the Recycle Bin folder
|
||||
//system("explorer.exe /N,::{645FF040-5081-101B-9F08-00AA002F954E}");
|
||||
std::wstring szCmd = L"explorer.exe";
|
||||
std::wstring szParm= L"/N,::{645FF040-5081-101B-9F08-00AA002F954E}";
|
||||
ShellExecute(NULL,L"open",szCmd.c_str(),szParm.c_str(),NULL,SW_SHOW);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ BOOL CALLBACK EnumWindowProc ( HWND hWnd, LPARAM lParam )
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -186,7 +186,7 @@ UINT Update(UINT id)
|
||||
{
|
||||
if (processName)
|
||||
{
|
||||
if(EnumProcessModules(hProcess, hMod, sizeof(hMod), &cbNeeded))
|
||||
if (EnumProcessModules(hProcess, hMod, sizeof(hMod), &cbNeeded))
|
||||
{
|
||||
if (GetModuleBaseName(hProcess, hMod[0], buffer, sizeof(buffer)))
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ __declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
struct SpeedFanData
|
||||
struct SpeedFanData
|
||||
{
|
||||
WORD version;
|
||||
WORD flags;
|
||||
@ -50,7 +50,7 @@ struct SpeedFanData
|
||||
INT volts[32];
|
||||
};
|
||||
|
||||
enum SensorType
|
||||
enum SensorType
|
||||
{
|
||||
TYPE_TEMP,
|
||||
TYPE_FAN,
|
||||
@ -73,7 +73,7 @@ static std::map<UINT, UINT> g_Numbers;
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -99,15 +99,15 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
if (_wcsicmp(L"C", scale) == 0)
|
||||
{
|
||||
g_Scales[id] = SCALE_CENTIGRADE;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"F", scale) == 0)
|
||||
{
|
||||
g_Scales[id] = SCALE_FARENHEIT;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"K", scale) == 0)
|
||||
{
|
||||
g_Scales[id] = SCALE_KELVIN;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"SpeedFanScale=";
|
||||
@ -118,15 +118,15 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"FAN", type) == 0)
|
||||
{
|
||||
g_Types[id] = TYPE_FAN;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"VOLTAGE", type) == 0)
|
||||
{
|
||||
g_Types[id] = TYPE_VOLT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"SpeedFanType=";
|
||||
@ -137,7 +137,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LPCTSTR data = ReadConfigString(section, L"SpeedFanNumber", L"0");
|
||||
if (data)
|
||||
{
|
||||
@ -153,13 +153,13 @@ The function returns the new value.
|
||||
*/
|
||||
double Update2(UINT id)
|
||||
{
|
||||
double value = 0.0;
|
||||
|
||||
double value = 0.0;
|
||||
|
||||
std::map<UINT, SensorType>::const_iterator type = g_Types.find(id);
|
||||
std::map<UINT, TempScale>::const_iterator scale = g_Scales.find(id);
|
||||
std::map<UINT, UINT>::const_iterator number = g_Numbers.find(id);
|
||||
|
||||
if(type == g_Types.end() || number == g_Numbers.end())
|
||||
|
||||
if (type == g_Types.end() || number == g_Numbers.end())
|
||||
{
|
||||
return 0.0; // No id in the map. How this can be ????
|
||||
}
|
||||
@ -179,7 +179,7 @@ double Update2(UINT id)
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@ -216,10 +216,10 @@ bool ReadSharedData(SensorType type, TempScale scale, UINT number, double* value
|
||||
{
|
||||
SpeedFanData* ptr;
|
||||
HANDLE hData;
|
||||
|
||||
|
||||
hData = OpenFileMapping(FILE_MAP_READ, FALSE, L"SFSharedMemory_ALM");
|
||||
if (hData == NULL) return false;
|
||||
|
||||
|
||||
ptr = (SpeedFanData*)MapViewOfFile(hData, FILE_MAP_READ, 0, 0, 0);
|
||||
if (ptr == 0)
|
||||
{
|
||||
@ -229,7 +229,7 @@ bool ReadSharedData(SensorType type, TempScale scale, UINT number, double* value
|
||||
|
||||
if (ptr->version == 1)
|
||||
{
|
||||
switch(type)
|
||||
switch(type)
|
||||
{
|
||||
case TYPE_TEMP:
|
||||
if (number < ptr->NumTemps)
|
||||
@ -272,7 +272,7 @@ bool ReadSharedData(SensorType type, TempScale scale, UINT number, double* value
|
||||
|
||||
UnmapViewOfFile(ptr);
|
||||
CloseHandle(hData);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ __declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
}
|
||||
|
||||
typedef struct
|
||||
typedef struct
|
||||
{
|
||||
int count; //Number of monitors
|
||||
HMONITOR m_Monitors[32]; //Monitor info
|
||||
@ -87,7 +87,7 @@ static std::map<UINT, UINT> g_Datas;
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -101,109 +101,109 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
/* Read our own settings from the ini-file */
|
||||
LPCTSTR type = ReadConfigString(section, L"SysInfoType", L"");
|
||||
if(type)
|
||||
if (type)
|
||||
{
|
||||
if (_wcsicmp(L"COMPUTER_NAME", type) == 0)
|
||||
{
|
||||
g_Types[id] = COMPUTER_NAME;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"USER_NAME", type) == 0)
|
||||
{
|
||||
g_Types[id] = USER_NAME;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"WORK_AREA", type) == 0)
|
||||
{
|
||||
g_Types[id] = WORK_AREA;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"SCREEN_SIZE", type) == 0)
|
||||
{
|
||||
g_Types[id] = SCREEN_SIZE;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"RAS_STATUS", type) == 0)
|
||||
{
|
||||
g_Types[id] = RAS_STATUS;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"OS_VERSION", type) == 0)
|
||||
{
|
||||
g_Types[id] = OS_VERSION;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"OS_BITS", type) == 0)
|
||||
{
|
||||
g_Types[id] = OS_BITS;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"ADAPTER_DESCRIPTION", type) == 0)
|
||||
{
|
||||
g_Types[id] = ADAPTER_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"NET_MASK", type) == 0)
|
||||
{
|
||||
g_Types[id] = NET_MASK;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"IP_ADDRESS", type) == 0)
|
||||
{
|
||||
g_Types[id] = IP_ADDRESS;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"GATEWAY_ADDRESS", type) == 0)
|
||||
{
|
||||
g_Types[id] = GATEWAY_ADDRESS;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"HOST_NAME", type) == 0)
|
||||
{
|
||||
g_Types[id] = HOST_NAME;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"DOMAIN_NAME", type) == 0)
|
||||
{
|
||||
g_Types[id] = DOMAIN_NAME;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"DNS_SERVER", type) == 0)
|
||||
{
|
||||
g_Types[id] = DNS_SERVER;
|
||||
}
|
||||
}
|
||||
|
||||
else if (_wcsicmp(L"WORK_AREA_TOP", type) == 0)
|
||||
{
|
||||
g_Types[id] = WORK_AREA_TOP;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"WORK_AREA_LEFT", type) == 0)
|
||||
{
|
||||
g_Types[id] = WORK_AREA_LEFT;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"WORK_AREA_WIDTH", type) == 0)
|
||||
{
|
||||
g_Types[id] = WORK_AREA_WIDTH;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"WORK_AREA_HEIGHT", type) == 0)
|
||||
{
|
||||
g_Types[id] = WORK_AREA_HEIGHT;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"SCREEN_WIDTH", type) == 0)
|
||||
{
|
||||
g_Types[id] = SCREEN_WIDTH;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"SCREEN_HEIGHT", type) == 0)
|
||||
{
|
||||
g_Types[id] = SCREEN_HEIGHT;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"NUM_MONITORS", type) == 0)
|
||||
{
|
||||
g_Types[id] = NUM_MONITORS;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"VIRTUAL_SCREEN_TOP", type) == 0)
|
||||
{
|
||||
g_Types[id] = VIRTUAL_SCREEN_TOP;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"VIRTUAL_SCREEN_LEFT", type) == 0)
|
||||
{
|
||||
g_Types[id] = VIRTUAL_SCREEN_LEFT;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"VIRTUAL_SCREEN_WIDTH", type) == 0)
|
||||
{
|
||||
g_Types[id] = VIRTUAL_SCREEN_WIDTH;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"VIRTUAL_SCREEN_HEIGHT", type) == 0)
|
||||
{
|
||||
g_Types[id] = VIRTUAL_SCREEN_HEIGHT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"SysInfoType=";
|
||||
@ -248,7 +248,7 @@ std::wstring ConvertToWide(LPCSTR str)
|
||||
This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static WCHAR buffer[4096];
|
||||
UINT data;
|
||||
@ -256,8 +256,8 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
std::map<UINT, TYPE>::iterator typeIter = g_Types.find(id);
|
||||
std::map<UINT, UINT>::iterator dataIter = g_Datas.find(id);
|
||||
|
||||
if(typeIter == g_Types.end()) return NULL;
|
||||
if(dataIter == g_Datas.end())
|
||||
if (typeIter == g_Types.end()) return NULL;
|
||||
if (dataIter == g_Datas.end())
|
||||
{
|
||||
data = 0;
|
||||
}
|
||||
@ -321,11 +321,11 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
if (data >= 1000)
|
||||
{
|
||||
data = data-999;
|
||||
for(UINT i=0; i<ipTable->dwNumEntries; i++)
|
||||
for (UINT i=0; i<ipTable->dwNumEntries; i++)
|
||||
{
|
||||
if((ipTable->table[i].wType)&MIB_IPADDR_DISCONNECTED) continue;
|
||||
if ((ipTable->table[i].wType)&MIB_IPADDR_DISCONNECTED) continue;
|
||||
data--;
|
||||
if(data==0)
|
||||
if (data==0)
|
||||
{
|
||||
DWORD ip = ipTable->table[i].dwAddr;
|
||||
wsprintf(buffer, L"%i.%i.%i.%i", ip%256, (ip>>8)%256, (ip>>16)%256, (ip>>24)%256);
|
||||
@ -423,8 +423,8 @@ double Update2(UINT id)
|
||||
std::map<UINT, TYPE>::iterator typeIter = g_Types.find(id);
|
||||
std::map<UINT, UINT>::iterator dataIter = g_Datas.find(id);
|
||||
|
||||
if(typeIter == g_Types.end()) return NULL;
|
||||
if(dataIter == g_Datas.end())
|
||||
if (typeIter == g_Types.end()) return NULL;
|
||||
if (dataIter == g_Datas.end())
|
||||
{
|
||||
data = 0;
|
||||
}
|
||||
@ -433,16 +433,16 @@ double Update2(UINT id)
|
||||
data = (*dataIter).second;
|
||||
}
|
||||
|
||||
if(data) //For speed purposes, only check if they specify a non-primary monitor.
|
||||
if (data) //For speed purposes, only check if they specify a non-primary monitor.
|
||||
{
|
||||
if(GetSystemMetrics(SM_CMONITORS)>32)
|
||||
if (GetSystemMetrics(SM_CMONITORS)>32)
|
||||
{
|
||||
std::wstring error = L"That's alot of monitors! 32 is the max.";
|
||||
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONERROR);
|
||||
exit(-1);
|
||||
}
|
||||
m_Monitors.count = 0;
|
||||
EnumDisplayMonitors(NULL, NULL, MyInfoEnumProc, (LPARAM)(&m_Monitors));
|
||||
EnumDisplayMonitors(NULL, NULL, MyInfoEnumProc, (LPARAM)(&m_Monitors));
|
||||
}
|
||||
|
||||
|
||||
@ -633,17 +633,17 @@ BOOL CheckConnection()
|
||||
static HRASCONN g_hRasConn=NULL;
|
||||
RASCONNSTATUS rasStatus;
|
||||
LPRASCONN lpRasConn=NULL;
|
||||
DWORD cbBuf=0;
|
||||
DWORD cConn=1;
|
||||
DWORD dwRet=0;
|
||||
DWORD cbBuf=0;
|
||||
DWORD cConn=1;
|
||||
DWORD dwRet=0;
|
||||
|
||||
if(g_hRasConn==NULL) {
|
||||
// Enumerate connections
|
||||
if (g_hRasConn==NULL) {
|
||||
// Enumerate connections
|
||||
cbBuf=sizeof(RASCONN);
|
||||
if(((lpRasConn=(LPRASCONN)malloc((UINT)cbBuf))!= NULL)) {
|
||||
if (((lpRasConn=(LPRASCONN)malloc((UINT)cbBuf))!= NULL)) {
|
||||
lpRasConn->dwSize=sizeof(RASCONN);
|
||||
if(0==RasEnumConnections(lpRasConn, &cbBuf, &cConn)) {
|
||||
if(cConn!=0) {
|
||||
if (0==RasEnumConnections(lpRasConn, &cbBuf, &cConn)) {
|
||||
if (cConn!=0) {
|
||||
g_hRasConn=lpRasConn->hrasconn;
|
||||
}
|
||||
}
|
||||
@ -651,19 +651,19 @@ BOOL CheckConnection()
|
||||
}
|
||||
}
|
||||
|
||||
if(g_hRasConn!=NULL) {
|
||||
if (g_hRasConn!=NULL) {
|
||||
// get connection status
|
||||
rasStatus.dwSize=sizeof(RASCONNSTATUS);
|
||||
dwRet=RasGetConnectStatus(g_hRasConn, &rasStatus );
|
||||
if(dwRet==0) {
|
||||
if (dwRet==0) {
|
||||
// Check for connection
|
||||
if(rasStatus.rasconnstate==RASCS_Connected) return TRUE;
|
||||
if (rasStatus.rasconnstate==RASCS_Connected) return TRUE;
|
||||
} else {
|
||||
g_hRasConn=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UINT GetPluginVersion()
|
||||
|
@ -45,28 +45,28 @@ DexpotMeasure* DexpotMeasure::CreateMeasure(HMODULE instance, UINT id, LPCTSTR i
|
||||
{
|
||||
std::wstring TypeString(ReadConfigString(section, _T("VDMeasureType"), _T("")));
|
||||
|
||||
if(TypeString == _T("VDMActive")) return new DexpotVDMActiveMeasure(instance, id);
|
||||
else if(TypeString == _T("DesktopCount")) return new DexpotDesktopCountMeasure(instance, id);
|
||||
else if(TypeString == _T("CurrentDesktop")) return new DexpotCurrentDesktopMeasure(instance, id);
|
||||
else if(TypeString == _T("SwitchDesktop")) return new DexpotSwitchDesktopMeasure(instance, id);
|
||||
else if(TypeString == _T("Screenshot")) return new DexpotScreenshotMeasure(instance, id);
|
||||
else if(TypeString == _T("DesktopName")) return new DexpotDesktopNameMeasure(instance, id);
|
||||
else if(TypeString == _T("DesktopWallpaper")) return new DexpotDesktopWallpaperMeasure(instance, id);
|
||||
else if(TypeString == _T("Command")) return new DexpotCommandMeasure(instance, id);
|
||||
if (TypeString == _T("VDMActive")) return new DexpotVDMActiveMeasure(instance, id);
|
||||
else if (TypeString == _T("DesktopCount")) return new DexpotDesktopCountMeasure(instance, id);
|
||||
else if (TypeString == _T("CurrentDesktop")) return new DexpotCurrentDesktopMeasure(instance, id);
|
||||
else if (TypeString == _T("SwitchDesktop")) return new DexpotSwitchDesktopMeasure(instance, id);
|
||||
else if (TypeString == _T("Screenshot")) return new DexpotScreenshotMeasure(instance, id);
|
||||
else if (TypeString == _T("DesktopName")) return new DexpotDesktopNameMeasure(instance, id);
|
||||
else if (TypeString == _T("DesktopWallpaper")) return new DexpotDesktopWallpaperMeasure(instance, id);
|
||||
else if (TypeString == _T("Command")) return new DexpotCommandMeasure(instance, id);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UINT DexpotMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
{
|
||||
if(InstanceCount == 0)
|
||||
if (InstanceCount == 0)
|
||||
{
|
||||
hWndRainmeterControl = FindWindow(_T("DummyRainWClass"), _T("Rainmeter control window"));
|
||||
hWndMessageWindow = CreateMessageWindow();
|
||||
}
|
||||
InstanceCount++;
|
||||
|
||||
if(!PluginRegistered && FindDexpotWindow())
|
||||
if (!PluginRegistered && FindDexpotWindow())
|
||||
{
|
||||
SendNotifyMessage(hWndDexpot, DEX_REGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow);
|
||||
CurrentDesktop = (int) SendMessage(hWndDexpot, DEX_GETCURRENTDESKTOP, 0, 0);
|
||||
@ -82,9 +82,9 @@ UINT DexpotMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
void DexpotMeasure::Finalize()
|
||||
{
|
||||
InstanceCount--;
|
||||
if(InstanceCount == 0)
|
||||
if (InstanceCount == 0)
|
||||
{
|
||||
if(PluginRegistered)
|
||||
if (PluginRegistered)
|
||||
{
|
||||
SendNotifyMessage(hWndDexpot, DEX_UNREGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow);
|
||||
PluginRegistered = FALSE;
|
||||
@ -113,7 +113,7 @@ void DexpotMeasure::OnDexpotStarted()
|
||||
|
||||
BOOL DexpotMeasure::FindDexpotWindow()
|
||||
{
|
||||
if(IsWindow(hWndDexpot)) return TRUE;
|
||||
if (IsWindow(hWndDexpot)) return TRUE;
|
||||
hWndDexpot = FindWindow(DEXPOTCLASS, DEXPOTTITLE);
|
||||
return hWndDexpot != NULL;
|
||||
}
|
||||
@ -153,14 +153,14 @@ LRESULT CALLBACK DexpotMeasure::WindowProc(HWND hWnd, UINT message, WPARAM wPara
|
||||
{
|
||||
case DEX_SWITCHED:
|
||||
CurrentDesktop = HIWORD(lParam);
|
||||
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
{
|
||||
(*i)->OnSwitched(LOWORD(lParam), HIWORD(lParam), LOWORD(wParam), HIWORD(wParam));
|
||||
}
|
||||
return 0;
|
||||
|
||||
case DEX_DESKTOPCOUNTCHANGED:
|
||||
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
{
|
||||
(*i)->OnDesktopCountChanged((int)wParam);
|
||||
}
|
||||
@ -168,21 +168,21 @@ LRESULT CALLBACK DexpotMeasure::WindowProc(HWND hWnd, UINT message, WPARAM wPara
|
||||
|
||||
case DEX_SHUTDOWN:
|
||||
PluginRegistered = FALSE;
|
||||
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
{
|
||||
(*i)->OnShutdown();
|
||||
}
|
||||
return 0;
|
||||
|
||||
case DEX_DESKTOPCONFIGURATIONCHANGED:
|
||||
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
{
|
||||
(*i)->OnDesktopConfigurationChanged();
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_COPYDATA:
|
||||
if((HWND) wParam == hWndDexpot)
|
||||
if ((HWND) wParam == hWndDexpot)
|
||||
{
|
||||
COPYDATASTRUCT *cds = (COPYDATASTRUCT*) lParam;
|
||||
switch(LOWORD(cds->dwData))
|
||||
@ -198,17 +198,17 @@ LRESULT CALLBACK DexpotMeasure::WindowProc(HWND hWnd, UINT message, WPARAM wPara
|
||||
return 0;
|
||||
|
||||
default:
|
||||
if(message == WM_DEXPOTSTARTED)
|
||||
if (message == WM_DEXPOTSTARTED)
|
||||
{
|
||||
hWndDexpot = (HWND) wParam;
|
||||
if(!hWndDexpot) FindDexpotWindow();
|
||||
if(hWndDexpot)
|
||||
if (!hWndDexpot) FindDexpotWindow();
|
||||
if (hWndDexpot)
|
||||
{
|
||||
SendMessage(hWndDexpot, DEX_REGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow);
|
||||
CurrentDesktop = (int) SendMessage(hWndDexpot, DEX_GETCURRENTDESKTOP, 0, 0);
|
||||
PluginRegistered = TRUE;
|
||||
}
|
||||
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
{
|
||||
(*i)->OnDexpotStarted();
|
||||
}
|
||||
@ -222,7 +222,7 @@ LRESULT CALLBACK DexpotMeasure::WindowProc(HWND hWnd, UINT message, WPARAM wPara
|
||||
|
||||
/*
|
||||
* DexpotDesktopCountMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotDesktopCountMeasure::DexpotDesktopCountMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
|
||||
|
||||
@ -230,11 +230,11 @@ UINT DexpotDesktopCountMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
{
|
||||
DesktopCount = 0;
|
||||
OnChange = ReadConfigString(section, _T("VDOnChange"), _T(""));
|
||||
|
||||
|
||||
CountType = Total;
|
||||
LPCTSTR TypeString = ReadConfigString(section, _T("VDDesktopCount"), _T(""));
|
||||
if(_tcsicmp(TypeString, _T("X")) == 0) CountType = Columns;
|
||||
else if(_tcsicmp(TypeString, _T("Y")) == 0) CountType = Rows;
|
||||
if (_tcsicmp(TypeString, _T("X")) == 0) CountType = Columns;
|
||||
else if (_tcsicmp(TypeString, _T("Y")) == 0) CountType = Rows;
|
||||
|
||||
DexpotMeasure::Initialize(iniFile, section);
|
||||
return 20;
|
||||
@ -242,25 +242,25 @@ UINT DexpotDesktopCountMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
|
||||
void DexpotDesktopCountMeasure::InitializeData()
|
||||
{
|
||||
if(PluginRegistered) DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0);
|
||||
if (PluginRegistered) DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0);
|
||||
}
|
||||
|
||||
UINT DexpotDesktopCountMeasure::Update()
|
||||
{
|
||||
if(CountType == Rows) return 1;
|
||||
if (CountType == Rows) return 1;
|
||||
else return DesktopCount;
|
||||
}
|
||||
|
||||
void DexpotDesktopCountMeasure::OnDesktopCountChanged(int NewCount)
|
||||
{
|
||||
DesktopCount = NewCount;
|
||||
if(OnChange.length()) SendBang(OnChange);
|
||||
if (OnChange.length()) SendBang(OnChange);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* DexpotCurrentDesktopMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotCurrentDesktopMeasure::DexpotCurrentDesktopMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
|
||||
|
||||
@ -279,13 +279,13 @@ UINT DexpotCurrentDesktopMeasure::Update()
|
||||
|
||||
void DexpotCurrentDesktopMeasure::OnSwitched(int FromDesktop, int ToDesktop, WORD Flags, WORD Trigger)
|
||||
{
|
||||
if(OnChange.length()) SendBang(OnChange);
|
||||
if (OnChange.length()) SendBang(OnChange);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* DexpotVDMActiveMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotVDMActiveMeasure::DexpotVDMActiveMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {};
|
||||
|
||||
@ -305,30 +305,30 @@ UINT DexpotVDMActiveMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
|
||||
void DexpotVDMActiveMeasure::OnShutdown()
|
||||
{
|
||||
if(OnDeactivate.length()) SendBang(OnDeactivate);
|
||||
if (OnDeactivate.length()) SendBang(OnDeactivate);
|
||||
}
|
||||
|
||||
void DexpotVDMActiveMeasure::OnDexpotStarted()
|
||||
{
|
||||
if(OnActivate.length()) SendBang(OnActivate);
|
||||
if (OnActivate.length()) SendBang(OnActivate);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* DexpotSwitchDesktopMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotSwitchDesktopMeasure::DexpotSwitchDesktopMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
|
||||
|
||||
void DexpotSwitchDesktopMeasure::ExecuteBang(LPCTSTR args)
|
||||
{
|
||||
if(PluginRegistered)
|
||||
if (PluginRegistered)
|
||||
{
|
||||
DWORD Desktop;
|
||||
|
||||
if(_tcsicmp(args, _T("next")) == 0) Desktop = MAKELPARAM(0, 1);
|
||||
else if(_tcsicmp(args, _T("prev")) == 0) Desktop = MAKELPARAM(0, 2);
|
||||
else if(_tcsicmp(args, _T("back")) == 0) Desktop = MAKELPARAM(0, 3);
|
||||
if (_tcsicmp(args, _T("next")) == 0) Desktop = MAKELPARAM(0, 1);
|
||||
else if (_tcsicmp(args, _T("prev")) == 0) Desktop = MAKELPARAM(0, 2);
|
||||
else if (_tcsicmp(args, _T("back")) == 0) Desktop = MAKELPARAM(0, 3);
|
||||
else Desktop = _ttoi(args);
|
||||
|
||||
SendNotifyMessage(hWndDexpot, DEX_SWITCHDESKTOP, 0, Desktop);
|
||||
@ -338,7 +338,7 @@ void DexpotSwitchDesktopMeasure::ExecuteBang(LPCTSTR args)
|
||||
|
||||
/*
|
||||
* DexpotScreenshotMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotScreenshotMeasure::DexpotScreenshotMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
|
||||
|
||||
@ -356,7 +356,7 @@ UINT DexpotScreenshotMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
|
||||
UINT DexpotScreenshotMeasure::Update()
|
||||
{
|
||||
if(RefreshOnUpdate && (DesktopNumber == 0 || DesktopNumber == CurrentDesktop))
|
||||
if (RefreshOnUpdate && (DesktopNumber == 0 || DesktopNumber == CurrentDesktop))
|
||||
{
|
||||
UpdateScreenshot();
|
||||
}
|
||||
@ -375,7 +375,7 @@ void DexpotScreenshotMeasure::InitializeData()
|
||||
|
||||
void DexpotScreenshotMeasure::OnSwitched(int FromDesktop, int ToDesktop, WORD Flags, WORD Trigger)
|
||||
{
|
||||
if(DesktopNumber == FromDesktop || DesktopNumber == 0)
|
||||
if (DesktopNumber == FromDesktop || DesktopNumber == 0)
|
||||
{
|
||||
UpdateScreenshot();
|
||||
}
|
||||
@ -385,11 +385,11 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
{
|
||||
int Desktop = DesktopNumber == 0 ? CurrentDesktop : DesktopNumber;
|
||||
int nBytes = 0;
|
||||
BYTE *pBytes = NULL;
|
||||
BYTE *pBytes = NULL;
|
||||
HANDLE fm;
|
||||
HANDLE mutex;
|
||||
|
||||
if(!IsWindow(hWndDexpot)) return;
|
||||
if (!IsWindow(hWndDexpot)) return;
|
||||
|
||||
int DesktopWidth = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPWIDTH, Desktop, 0);
|
||||
int DesktopHeight = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPHEIGHT, Desktop, 0);
|
||||
@ -398,9 +398,9 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
WaitForSingleObject(mutex, 2000);
|
||||
fm = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, DesktopWidth * DesktopHeight * 4, L"Local\\DexpotScreenshotFilemap");
|
||||
pBytes = (BYTE*) MapViewOfFile(fm, FILE_MAP_ALL_ACCESS, 0, 0, 0);
|
||||
if(pBytes) nBytes = (int) SendMessage(hWndDexpot, DEX_GETSCREENSHOT, Desktop, 0);
|
||||
if (pBytes) nBytes = (int) SendMessage(hWndDexpot, DEX_GETSCREENSHOT, Desktop, 0);
|
||||
|
||||
if(nBytes > 0 && nBytes == DesktopWidth * DesktopHeight * 4)
|
||||
if (nBytes > 0 && nBytes == DesktopWidth * DesktopHeight * 4)
|
||||
{
|
||||
HDC ScreenDC;
|
||||
HDC MemDC;
|
||||
@ -415,10 +415,10 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
int ScaledHeight = Height;
|
||||
int ScaledWidth = Width;
|
||||
|
||||
if(ScaledHeight == 0) ScaledHeight = (int) ((float) DesktopHeight * (ScaledWidth / (float) DesktopWidth) + .5f);
|
||||
if(ScaledWidth == 0) ScaledWidth = (int) ((float) DesktopWidth * (ScaledHeight / (float) DesktopHeight) + .5f);
|
||||
if(ScaledHeight == 0) ScaledHeight = DesktopHeight;
|
||||
if(ScaledWidth == 0) ScaledWidth = DesktopWidth;
|
||||
if (ScaledHeight == 0) ScaledHeight = (int) ((float) DesktopHeight * (ScaledWidth / (float) DesktopWidth) + .5f);
|
||||
if (ScaledWidth == 0) ScaledWidth = (int) ((float) DesktopWidth * (ScaledHeight / (float) DesktopHeight) + .5f);
|
||||
if (ScaledHeight == 0) ScaledHeight = DesktopHeight;
|
||||
if (ScaledWidth == 0) ScaledWidth = DesktopWidth;
|
||||
|
||||
ZeroMemory(&bmi.bmiHeader, sizeof(BITMAPINFOHEADER));
|
||||
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
@ -433,7 +433,7 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
MemDC = CreateCompatibleDC(ScreenDC);
|
||||
MemDC2 = CreateCompatibleDC(ScreenDC);
|
||||
OriginalBitmap = CreateCompatibleBitmap(ScreenDC, DesktopWidth, DesktopHeight);
|
||||
SetDIBits(MemDC2, OriginalBitmap, 0, DesktopHeight, pBytes, &bmi, 0);
|
||||
SetDIBits(MemDC2, OriginalBitmap, 0, DesktopHeight, pBytes, &bmi, 0);
|
||||
OldBitmap2 = SelectObject(MemDC2, (HGDIOBJ) OriginalBitmap);
|
||||
|
||||
nBytes = ScaledWidth * ScaledHeight * 4;
|
||||
@ -453,7 +453,7 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
bmfh.bfType = 0x4d42;
|
||||
|
||||
std::ofstream ofs(OutputFile.c_str(), std::ios_base::binary);
|
||||
if(ofs)
|
||||
if (ofs)
|
||||
{
|
||||
ofs.write((char*) &bmfh, sizeof(BITMAPFILEHEADER));
|
||||
ofs.write((char*) &bmi, sizeof(BITMAPINFOHEADER));
|
||||
@ -479,7 +479,7 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
|
||||
/*
|
||||
* DexpotDesktopNameMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotDesktopNameMeasure::DexpotDesktopNameMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
|
||||
|
||||
@ -492,7 +492,7 @@ UINT DexpotDesktopNameMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
LPCTSTR DexpotDesktopNameMeasure::GetString(UINT flags)
|
||||
{
|
||||
UINT Desktop = (DesktopNumber == 0 ? CurrentDesktop : DesktopNumber) - 1;
|
||||
if(Desktop >= 0 && Desktop < DesktopNames.size())
|
||||
if (Desktop >= 0 && Desktop < DesktopNames.size())
|
||||
{
|
||||
return DesktopNames[Desktop].c_str();
|
||||
}
|
||||
@ -505,18 +505,18 @@ LPCTSTR DexpotDesktopNameMeasure::GetString(UINT flags)
|
||||
|
||||
void DexpotDesktopNameMeasure::InitializeData()
|
||||
{
|
||||
if(PluginRegistered)
|
||||
if (PluginRegistered)
|
||||
{
|
||||
int DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0);
|
||||
DesktopNames.resize(DesktopCount);
|
||||
if(DesktopNumber == 0)
|
||||
if (DesktopNumber == 0)
|
||||
{
|
||||
for(int i = 1; i <= DesktopCount; i++)
|
||||
for (int i = 1; i <= DesktopCount; i++)
|
||||
{
|
||||
SendMessage(hWndDexpot, DEX_GETDESKTOPTITLE, i, (LPARAM) hWndMessageWindow);
|
||||
}
|
||||
}
|
||||
else if(DesktopNumber > 0 && DesktopNumber <= DesktopCount)
|
||||
else if (DesktopNumber > 0 && DesktopNumber <= DesktopCount)
|
||||
{
|
||||
SendMessage(hWndDexpot, DEX_GETDESKTOPTITLE, DesktopNumber, (LPARAM) hWndMessageWindow);
|
||||
}
|
||||
@ -535,14 +535,14 @@ void DexpotDesktopNameMeasure::OnDesktopCountChanged(int NewCount)
|
||||
|
||||
void DexpotDesktopNameMeasure::SetDesktopName(UINT Desktop, std::wstring &Name)
|
||||
{
|
||||
if(--Desktop >= DesktopNames.size()) DesktopNames.resize(Desktop + 1);
|
||||
if(Desktop >= 0) DesktopNames[Desktop] = Name;
|
||||
if (--Desktop >= DesktopNames.size()) DesktopNames.resize(Desktop + 1);
|
||||
if (Desktop >= 0) DesktopNames[Desktop] = Name;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* DexpotDesktopWallpaperMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotDesktopWallpaperMeasure::DexpotDesktopWallpaperMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
|
||||
|
||||
@ -554,12 +554,12 @@ UINT DexpotDesktopWallpaperMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
|
||||
LPCTSTR DexpotDesktopWallpaperMeasure::GetString(UINT flags)
|
||||
{
|
||||
if(DesktopNumber == 0)
|
||||
if (DesktopNumber == 0)
|
||||
{
|
||||
SystemParametersInfo(SPI_GETDESKWALLPAPER, STRINGBUFFER_SIZE, StringBuffer, 0);
|
||||
return StringBuffer;
|
||||
}
|
||||
else if(DesktopNumber > 0 && (UINT) DesktopNumber <= DesktopWallpapers.size())
|
||||
else if (DesktopNumber > 0 && (UINT) DesktopNumber <= DesktopWallpapers.size())
|
||||
{
|
||||
return DesktopWallpapers[DesktopNumber - 1].c_str();
|
||||
}
|
||||
@ -570,18 +570,18 @@ LPCTSTR DexpotDesktopWallpaperMeasure::GetString(UINT flags)
|
||||
|
||||
void DexpotDesktopWallpaperMeasure::InitializeData()
|
||||
{
|
||||
if(PluginRegistered)
|
||||
if (PluginRegistered)
|
||||
{
|
||||
int DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0);
|
||||
DesktopWallpapers.resize(DesktopCount);
|
||||
if(DesktopNumber == 0)
|
||||
if (DesktopNumber == 0)
|
||||
{
|
||||
for(int i = 1; i <= DesktopCount; i++)
|
||||
for (int i = 1; i <= DesktopCount; i++)
|
||||
{
|
||||
SendMessage(hWndDexpot, DEX_GETDESKTOPWALLPAPER, i, (LPARAM) hWndMessageWindow);
|
||||
}
|
||||
}
|
||||
else if(DesktopNumber > 0 && DesktopNumber <= DesktopCount)
|
||||
else if (DesktopNumber > 0 && DesktopNumber <= DesktopCount)
|
||||
{
|
||||
SendMessage(hWndDexpot, DEX_GETDESKTOPWALLPAPER, DesktopNumber, (LPARAM) hWndMessageWindow);
|
||||
}
|
||||
@ -604,20 +604,20 @@ void DexpotDesktopWallpaperMeasure::OnDesktopCountChanged(int NewCount)
|
||||
|
||||
void DexpotDesktopWallpaperMeasure::SetDesktopWallpaper(UINT Desktop, std::wstring &Wallpaper)
|
||||
{
|
||||
if(--Desktop >= DesktopWallpapers.size()) DesktopWallpapers.resize(Desktop + 1);
|
||||
if(Desktop >= 0) DesktopWallpapers[Desktop] = Wallpaper;
|
||||
if (--Desktop >= DesktopWallpapers.size()) DesktopWallpapers.resize(Desktop + 1);
|
||||
if (Desktop >= 0) DesktopWallpapers[Desktop] = Wallpaper;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* DexpotCommandMeasure
|
||||
*
|
||||
*
|
||||
*/
|
||||
DexpotCommandMeasure::DexpotCommandMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
|
||||
|
||||
void DexpotCommandMeasure::ExecuteBang(LPCTSTR args)
|
||||
{
|
||||
if(PluginRegistered)
|
||||
if (PluginRegistered)
|
||||
{
|
||||
COPYDATASTRUCT cds;
|
||||
|
||||
|
@ -28,7 +28,7 @@ std::map<std::wstring, VirtuaWinMeasure::MeasureType> VirtuaWinMeasure::StringTo
|
||||
|
||||
VirtuaWinMeasure::VirtuaWinMeasure(HMODULE instance, UINT id) : VDMeasure(instance, id)
|
||||
{
|
||||
if(StringToType.size() == 0)
|
||||
if (StringToType.size() == 0)
|
||||
{
|
||||
StringToType.insert(std::make_pair(std::wstring(L"VDMActive"), VDMActive));
|
||||
StringToType.insert(std::make_pair(std::wstring(L"DesktopCount"), DesktopCountTotal));
|
||||
@ -45,7 +45,7 @@ UINT VirtuaWinMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
{
|
||||
std::wstring TypeString(ReadConfigString(section, _T("VDMeasureType"), _T("")));
|
||||
std::map<std::wstring, MeasureType>::iterator i = StringToType.find(TypeString);
|
||||
if(i != StringToType.end())
|
||||
if (i != StringToType.end())
|
||||
{
|
||||
Type = i->second;
|
||||
}
|
||||
@ -62,9 +62,9 @@ UINT VirtuaWinMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
case DesktopCountTotal:
|
||||
{
|
||||
LPCTSTR CountType = ReadConfigString(section, _T("VDDesktopCount"), _T(""));
|
||||
if(_tcsicmp(CountType, _T("X")) == 0) Type = DesktopCountColumns;
|
||||
else if(_tcsicmp(CountType, _T("Y")) == 0) Type = DesktopCountRows;
|
||||
if(FindVirtuaWinWindow())
|
||||
if (_tcsicmp(CountType, _T("X")) == 0) Type = DesktopCountColumns;
|
||||
else if (_tcsicmp(CountType, _T("Y")) == 0) Type = DesktopCountRows;
|
||||
if (FindVirtuaWinWindow())
|
||||
{
|
||||
return (UINT) SendMessage(vwHandle, VW_DESKTOP_SIZE, 0, 0);
|
||||
}
|
||||
@ -81,7 +81,7 @@ void VirtuaWinMeasure::Finalize()
|
||||
|
||||
UINT VirtuaWinMeasure::Update()
|
||||
{
|
||||
if(!FindVirtuaWinWindow())
|
||||
if (!FindVirtuaWinWindow())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -130,7 +130,7 @@ void VirtuaWinMeasure::ExecuteBang(LPCTSTR args)
|
||||
{
|
||||
INT32 Desktop;
|
||||
|
||||
if(!FindVirtuaWinWindow()) return;
|
||||
if (!FindVirtuaWinWindow()) return;
|
||||
|
||||
switch(Type)
|
||||
{
|
||||
@ -142,7 +142,7 @@ void VirtuaWinMeasure::ExecuteBang(LPCTSTR args)
|
||||
|
||||
BOOL VirtuaWinMeasure::FindVirtuaWinWindow()
|
||||
{
|
||||
if(IsWindow(vwHandle)) return TRUE;
|
||||
if (IsWindow(vwHandle)) return TRUE;
|
||||
vwHandle = FindWindow(_T("VirtuaWinMainClass"), _T("VirtuaWinMainClass"));
|
||||
return vwHandle != NULL;
|
||||
}
|
||||
|
@ -24,43 +24,43 @@
|
||||
This plugin aims to give Rainmeter skins access to various virtual desktop
|
||||
managers through a common interface. The following VDMs are supported:
|
||||
|
||||
* Dexpot
|
||||
* VirtuaWin
|
||||
* Dexpot
|
||||
* VirtuaWin
|
||||
|
||||
To add support for another virtual desktop manager,
|
||||
|
||||
1) implement a new class derived from VDMeasure
|
||||
2) include its header file below
|
||||
3) add a new case for the "VDManager" config string in the Initialize
|
||||
funtion below
|
||||
1) implement a new class derived from VDMeasure
|
||||
2) include its header file below
|
||||
3) add a new case for the "VDManager" config string in the Initialize
|
||||
funtion below
|
||||
|
||||
Different types of measures are identified using the "VDMeasureType" config
|
||||
string, i.e.
|
||||
|
||||
[VirtualDesktopsMeasure]
|
||||
Measure=Plugin
|
||||
Plugin=VirtualDesktops.dll
|
||||
VDManager=SomeVDM
|
||||
VDMeasureType=...
|
||||
|
||||
[VirtualDesktopsMeasure]
|
||||
Measure=Plugin
|
||||
Plugin=VirtualDesktops.dll
|
||||
VDManager=SomeVDM
|
||||
VDMeasureType=...
|
||||
|
||||
The following basic measure types have to be implemented:
|
||||
|
||||
* VDMActive: returns 1 when the VDM is running, 0 otherwise
|
||||
* VDMActive: returns 1 when the VDM is running, 0 otherwise
|
||||
|
||||
* DesktopCount: returns the number of virtual desktops available; when
|
||||
"VDDesktopCount=X" or "VDDesktopCount=Y" is given, returns
|
||||
the number of columns or rows, respectively, in a grid of
|
||||
desktops
|
||||
* DesktopCount: returns the number of virtual desktops available; when
|
||||
"VDDesktopCount=X" or "VDDesktopCount=Y" is given, returns
|
||||
the number of columns or rows, respectively, in a grid of
|
||||
desktops
|
||||
|
||||
* CurrentDesktop: returns the number of the currently active desktop
|
||||
* CurrentDesktop: returns the number of the currently active desktop
|
||||
|
||||
* SwitchDesktop: when sent a desktop number as a bang, switches to the
|
||||
corresponding desktop
|
||||
* SwitchDesktop: when sent a desktop number as a bang, switches to the
|
||||
corresponding desktop
|
||||
|
||||
You're welcome to add any other measure types that suit the feature set of
|
||||
the virtual desktop manager in question. Examples can be found in the
|
||||
existing implementations.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "DexpotMeasure.h"
|
||||
@ -92,29 +92,29 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
VDMeasure *Measure = NULL;
|
||||
LPCTSTR VDManager = ReadConfigString(section, _T("VDManager"), _T(""));
|
||||
|
||||
if(_tcsicmp(VDManager, _T("Dexpot")) == 0)
|
||||
|
||||
if (_tcsicmp(VDManager, _T("Dexpot")) == 0)
|
||||
{
|
||||
Measure = DexpotMeasure::CreateMeasure(instance, id, iniFile, section);
|
||||
}
|
||||
else if(_tcsicmp(VDManager, _T("VirtuaWin")) == 0)
|
||||
else if (_tcsicmp(VDManager, _T("VirtuaWin")) == 0)
|
||||
{
|
||||
Measure = new VirtuaWinMeasure(instance, id);
|
||||
}
|
||||
|
||||
if(Measure)
|
||||
if (Measure)
|
||||
{
|
||||
Measures.insert(std::make_pair(id, Measure));
|
||||
return Measure->Initialize(iniFile, section);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT Update(UINT id)
|
||||
{
|
||||
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
||||
if(i != Measures.end())
|
||||
if (i != Measures.end())
|
||||
{
|
||||
return i->second->Update();
|
||||
}
|
||||
@ -125,7 +125,7 @@ UINT Update(UINT id)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
||||
if(i != Measures.end())
|
||||
if (i != Measures.end())
|
||||
{
|
||||
return i->second->GetString(flags);
|
||||
}
|
||||
@ -136,7 +136,7 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
void ExecuteBang(LPCTSTR args, UINT id)
|
||||
{
|
||||
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
||||
if(i != Measures.end())
|
||||
if (i != Measures.end())
|
||||
{
|
||||
i->second->ExecuteBang(args);
|
||||
}
|
||||
@ -145,7 +145,7 @@ void ExecuteBang(LPCTSTR args, UINT id)
|
||||
void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
||||
if(i != Measures.end())
|
||||
if (i != Measures.end())
|
||||
{
|
||||
i->second->Finalize();
|
||||
delete i->second;
|
||||
|
@ -76,7 +76,7 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam);
|
||||
void Log(const WCHAR* string);
|
||||
void ParseData(UrlData* urlData, LPCSTR parseData);
|
||||
|
||||
CRITICAL_SECTION g_CriticalSection;
|
||||
CRITICAL_SECTION g_CriticalSection;
|
||||
bool g_Initialized = false;
|
||||
|
||||
static std::map<UINT, UrlData*> g_UrlData;
|
||||
@ -290,7 +290,7 @@ void FillCharacterEntityReferences()
|
||||
g_CERs[L"lsaquo"] = (WCHAR)8249;
|
||||
g_CERs[L"rsaquo"] = (WCHAR)8250;
|
||||
g_CERs[L"euro"] = (WCHAR)8364;
|
||||
|
||||
|
||||
// for ISO 8859-1 characters
|
||||
g_CERs[L"nbsp"] = (WCHAR)160;
|
||||
g_CERs[L"iexcl"] = (WCHAR)161;
|
||||
@ -388,7 +388,7 @@ void FillCharacterEntityReferences()
|
||||
g_CERs[L"yacute"] = (WCHAR)253;
|
||||
g_CERs[L"thorn"] = (WCHAR)254;
|
||||
g_CERs[L"yuml"] = (WCHAR)255;
|
||||
|
||||
|
||||
// for symbols, mathematical symbols, and Greek letters
|
||||
g_CERs[L"fnof"] = (WCHAR)402;
|
||||
g_CERs[L"Alpha"] = (WCHAR)913;
|
||||
@ -565,7 +565,7 @@ HWND FindMeterWindow(HWND parent = NULL)
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -577,7 +577,7 @@ HWND FindMeterWindow(HWND parent = NULL)
|
||||
*/
|
||||
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
LPCTSTR tmpSz;
|
||||
LPCTSTR tmpSz;
|
||||
|
||||
if (!g_Initialized)
|
||||
{
|
||||
@ -602,10 +602,10 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
data->proxy = ReadConfigString(section, L"ProxyServer", L"");
|
||||
data->downloadFile = ReadConfigString(section, L"DownloadFile", L"");
|
||||
data->debugFileLocation = ReadConfigString(section, L"Debug2File", L"c:\\WebParserDump.txt");
|
||||
|
||||
if(data->debugFileLocation.find(L"\\") == std::wstring::npos)
|
||||
|
||||
if (data->debugFileLocation.find(L"\\") == std::wstring::npos)
|
||||
{
|
||||
std::wstring str = data->iniFile.substr(0,data->iniFile.find_last_of(L"\\")+1);
|
||||
std::wstring str = data->iniFile.substr(0,data->iniFile.find_last_of(L"\\")+1);
|
||||
str += data->debugFileLocation;
|
||||
Log(str.c_str());
|
||||
data->debugFileLocation = str;
|
||||
@ -706,12 +706,12 @@ double Update2(UINT id)
|
||||
|
||||
// Find the data for this instance (the data structure is not changed by anyone so this should be safe)
|
||||
std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id);
|
||||
if(urlIter != g_UrlData.end())
|
||||
if (urlIter != g_UrlData.end())
|
||||
{
|
||||
urlData = (*urlIter).second;
|
||||
}
|
||||
|
||||
if (urlData)
|
||||
if (urlData)
|
||||
{
|
||||
if (urlData->download && urlData->regExp.empty() && urlData->url.find(L'[') == std::wstring::npos)
|
||||
{
|
||||
@ -749,7 +749,7 @@ double Update2(UINT id)
|
||||
{
|
||||
// Make sure that the thread is not writing to the result at the same time
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
|
||||
|
||||
if (!urlData->resultString.empty())
|
||||
{
|
||||
value = wcstod(urlData->resultString.c_str(), NULL);
|
||||
@ -837,7 +837,7 @@ unsigned __stdcall NetworkThreadProc(void* pParam)
|
||||
urlData->threadHandle = 0;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
return 0; // thread completed successfully
|
||||
return 0; // thread completed successfully
|
||||
}
|
||||
|
||||
void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
@ -851,12 +851,12 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
int ovector[OVECCOUNT];
|
||||
int rc;
|
||||
int flags = PCRE_UTF8;
|
||||
|
||||
|
||||
if (urlData->codepage == 0)
|
||||
{
|
||||
flags = 0;
|
||||
}
|
||||
|
||||
|
||||
// Compile the regular expression in the first argument
|
||||
re = pcre_compile(
|
||||
ConvertWideToUTF8(urlData->regExp.c_str()).c_str(), // the pattern
|
||||
@ -864,7 +864,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
&error, // for error message
|
||||
&erroffset, // for error offset
|
||||
NULL); // use default character tables
|
||||
|
||||
|
||||
if (re != NULL)
|
||||
{
|
||||
// Compilation succeeded: match the subject in the second argument
|
||||
@ -878,7 +878,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
}
|
||||
|
||||
dwSize = strlen(parseData);
|
||||
|
||||
|
||||
rc = pcre_exec(
|
||||
re, // the compiled pattern
|
||||
NULL, // no extra data - we didn't study the pattern
|
||||
@ -888,8 +888,8 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
0, // default options
|
||||
ovector, // output vector for substring information
|
||||
OVECCOUNT); // number of elements in the output vector
|
||||
|
||||
|
||||
|
||||
|
||||
if (rc >= 0)
|
||||
{
|
||||
if (rc == 0)
|
||||
@ -941,7 +941,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
log += L"] Not enough substrings!";
|
||||
Log(log.c_str());
|
||||
|
||||
// Clear the old result
|
||||
// Clear the old result
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
urlData->resultString.clear();
|
||||
if (urlData->download)
|
||||
@ -975,7 +975,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
|
||||
std::string szResult(substring_start, substring_length);
|
||||
|
||||
if (!((*i).second)->regExp.empty())
|
||||
if (!((*i).second)->regExp.empty())
|
||||
{
|
||||
// Change the index and parse the substring
|
||||
int index = (*i).second->stringIndex;
|
||||
@ -985,9 +985,9 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the result
|
||||
// Set the result
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
|
||||
|
||||
// Substitude the [measure] with szResult
|
||||
std::wstring wzResult = ConvertUTF8ToWide(szResult.c_str());
|
||||
std::wstring wzUrl = ((*i).second)->url;
|
||||
@ -1024,7 +1024,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
log += L"] Not enough substrings!";
|
||||
Log(log.c_str());
|
||||
|
||||
// Clear the old result
|
||||
// Clear the old result
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
((*i).second)->resultString.clear();
|
||||
if ((*i).second->download)
|
||||
@ -1076,7 +1076,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
}
|
||||
|
||||
// Release memory used for the compiled pattern
|
||||
// Release memory used for the compiled pattern
|
||||
pcre_free(re);
|
||||
}
|
||||
else
|
||||
@ -1114,7 +1114,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!urlData->finishAction.empty())
|
||||
if (!urlData->finishAction.empty())
|
||||
{
|
||||
HWND wnd = FindMeterWindow();
|
||||
|
||||
@ -1156,7 +1156,7 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
url = urlData->resultString;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
|
||||
std::wstring::size_type pos = url.find(L':');
|
||||
if (pos == std::wstring::npos && !url.empty()) // No protocol
|
||||
{
|
||||
@ -1420,8 +1420,8 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
||||
urlData->downloadedFile = fullpath;
|
||||
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
if (!urlData->finishAction.empty())
|
||||
|
||||
if (!urlData->finishAction.empty())
|
||||
{
|
||||
HWND wnd = FindMeterWindow();
|
||||
|
||||
@ -1505,20 +1505,20 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
||||
urlData->dlThreadHandle = 0;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
return 0; // thread completed successfully
|
||||
return 0; // thread completed successfully
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static std::wstring resultString;
|
||||
|
||||
std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id);
|
||||
|
||||
if(urlIter != g_UrlData.end())
|
||||
if (urlIter != g_UrlData.end())
|
||||
{
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
if (((*urlIter).second)->download)
|
||||
@ -1546,7 +1546,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id);
|
||||
|
||||
if(urlIter != g_UrlData.end())
|
||||
if (urlIter != g_UrlData.end())
|
||||
{
|
||||
if (((*urlIter).second)->threadHandle)
|
||||
{
|
||||
@ -1555,7 +1555,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
|
||||
TerminateThread(((*urlIter).second)->threadHandle, 0);
|
||||
(*urlIter).second->threadHandle = NULL;
|
||||
|
||||
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
}
|
||||
|
||||
@ -1566,7 +1566,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
|
||||
TerminateThread(((*urlIter).second)->dlThreadHandle, 0);
|
||||
(*urlIter).second->dlThreadHandle = NULL;
|
||||
|
||||
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
}
|
||||
|
||||
@ -1618,7 +1618,7 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload)
|
||||
std::wstring err = L"WebParser: Fetching URL: ";
|
||||
err += url;
|
||||
Log(err.c_str());
|
||||
|
||||
|
||||
DWORD flags = INTERNET_FLAG_RESYNCHRONIZE;
|
||||
if (forceReload)
|
||||
{
|
||||
@ -1662,14 +1662,14 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Determine the buffer size to hold the new data and the data
|
||||
// already written (if any).
|
||||
nBufferSize = *dwDataSize + dwSize;
|
||||
|
||||
|
||||
// Allocate the output buffer.
|
||||
lpOutPut = new BYTE[nBufferSize + 2];
|
||||
|
||||
|
||||
// Make sure the buffer is not the initial buffer.
|
||||
if (lpHolding != NULL)
|
||||
{
|
||||
@ -1695,7 +1695,7 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload)
|
||||
// End with double null
|
||||
lpOutPut[dwSize] = 0;
|
||||
lpOutPut[dwSize + 1] = 0;
|
||||
|
||||
|
||||
// Increment the number of buffers read.
|
||||
++nCounter;
|
||||
|
||||
@ -1703,7 +1703,7 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload)
|
||||
memset(lpData, 0, CHUNK_SIZE);
|
||||
}
|
||||
} while (TRUE);
|
||||
|
||||
|
||||
// Close the HINTERNET handle.
|
||||
InternetCloseHandle(hUrlDump);
|
||||
|
||||
@ -1734,7 +1734,7 @@ void ShowError(int lineNumber, WCHAR* errorMsg)
|
||||
|
||||
if (errorMsg == NULL)
|
||||
{
|
||||
if (dwErr == ERROR_INTERNET_EXTENDED_ERROR)
|
||||
if (dwErr == ERROR_INTERNET_EXTENDED_ERROR)
|
||||
{
|
||||
WCHAR szBuffer[1024];
|
||||
DWORD dwError, dwLen = 1024;
|
||||
@ -1757,10 +1757,10 @@ void ShowError(int lineNumber, WCHAR* errorMsg)
|
||||
{
|
||||
LPVOID lpMsgBuf = NULL;
|
||||
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_HMODULE |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_HMODULE |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
||||
GetModuleHandle(L"wininet"),
|
||||
@ -1768,10 +1768,10 @@ void ShowError(int lineNumber, WCHAR* errorMsg)
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL
|
||||
NULL
|
||||
);
|
||||
|
||||
if (lpMsgBuf == NULL)
|
||||
if (lpMsgBuf == NULL)
|
||||
{
|
||||
err += L"Unknown error";
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ PWLAN_INTERFACE_INFO_LIST pIntfList = NULL;
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -90,9 +90,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
DWORD dwErr;
|
||||
g_Instances++;
|
||||
//Create WINLAN API Handle
|
||||
if(hClient == NULL){
|
||||
if (hClient == NULL){
|
||||
dwErr = WlanOpenHandle( WLAN_API_VERSION, NULL, &dwNegotiatedVersion, &hClient );
|
||||
if( ERROR_SUCCESS != dwErr ){
|
||||
if ( ERROR_SUCCESS != dwErr ){
|
||||
WCHAR buffer[256];
|
||||
wsprintf(buffer, L"WifiStatus.dll: Unable to open WLAN API Handle. Error code (%d): %s",(int)dwErr,getDot11str(dwErr,5));
|
||||
Log(buffer);
|
||||
@ -100,9 +100,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
}
|
||||
//Query list of WLAN interfaces
|
||||
if(pIntfList == NULL){
|
||||
if (pIntfList == NULL){
|
||||
dwErr= WlanEnumInterfaces(hClient, NULL, &pIntfList);
|
||||
if(( ERROR_SUCCESS != dwErr) || (&pIntfList->dwNumberOfItems <= 0)){
|
||||
if (( ERROR_SUCCESS != dwErr) || (&pIntfList->dwNumberOfItems <= 0)){
|
||||
WCHAR buffer[256];
|
||||
wsprintf(buffer, L"WifiStatus.dll: Unable to find any WLAN interfaces/adapters. Error code %d",(int) dwErr);
|
||||
Log(buffer);
|
||||
@ -111,22 +111,22 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
//Select a WLAN interface, default 0.
|
||||
LPCTSTR data = ReadConfigString(section, L"WifiIntfID", L"");
|
||||
|
||||
|
||||
if ((data != NULL) && (_wcsicmp(L"", data) != 0)){
|
||||
if(_wtoi(data) < (int)pIntfList->dwNumberOfItems){
|
||||
if (_wtoi(data) < (int)pIntfList->dwNumberOfItems){
|
||||
pInterface = &pIntfList->InterfaceInfo[_wtoi(data)];
|
||||
} else {
|
||||
WCHAR buffer[256];
|
||||
wsprintf(buffer, L"WifiStatus.dll: Adapter is disabled or invalid (WifiIntfID=%s), fix INTF ID(default=0) or enable the adapter.",data);
|
||||
Log(buffer);
|
||||
pInterface = &pIntfList->InterfaceInfo[0];
|
||||
}
|
||||
pInterface = &pIntfList->InterfaceInfo[0];
|
||||
}
|
||||
} else {
|
||||
pInterface = &pIntfList->InterfaceInfo[0];
|
||||
pInterface = &pIntfList->InterfaceInfo[0];
|
||||
}
|
||||
//Select LIST style
|
||||
data = ReadConfigString(section, L"WifiListStyle", L"");
|
||||
|
||||
|
||||
if ((data != NULL) && (_wcsicmp(L"", data) != 0)){
|
||||
if ( (_wtoi(data) >= 0) && (_wtoi(data) <= 3)){
|
||||
g_meas_data[id].listStyle = _wtoi(data);
|
||||
@ -135,7 +135,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
wsprintf(buffer, L"WifiStatus.dll: Invalid List Style given (WifiListStyle=%s), defaulting to 0.",data);
|
||||
Log(buffer);
|
||||
g_meas_data[id].listStyle = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
g_meas_data[id].listStyle = 0;
|
||||
}
|
||||
@ -151,29 +151,29 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
wsprintf(buffer, L"WifiStatus.dll: Invalid List Limit given (WifiListLimit=%s), defaulting to 5.",data);
|
||||
Log(buffer);
|
||||
g_meas_data[id].listMax = 5;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
g_meas_data[id].listMax = 5;
|
||||
}
|
||||
//Select type of measure
|
||||
MEASURETYPE infoType = UNKNOWN;
|
||||
LPCTSTR type = ReadConfigString(section, L"WifiInfoType", L"");
|
||||
if(type){
|
||||
if (type){
|
||||
if (_wcsicmp(L"SSID", type) == 0){
|
||||
infoType=SSID;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"QUALITY", type) == 0){
|
||||
infoType=QUALITY;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"ENCRYPTION", type) == 0){
|
||||
infoType=ENCRYPTION;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"AUTH", type) == 0){
|
||||
infoType=AUTH;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"LIST", type) == 0){
|
||||
infoType=LIST;
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(L"PHY", type) == 0){
|
||||
infoType=PHY;
|
||||
} else {
|
||||
@ -202,11 +202,11 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
*/
|
||||
UINT Update(UINT id)
|
||||
{
|
||||
if(pInterface == NULL) return NULL;
|
||||
if (pInterface == NULL) return NULL;
|
||||
|
||||
//Get measure id, and identify type
|
||||
//std::map<UINT, MEASURETYPE>::iterator typeIter = g_Types.find(id);
|
||||
//if(typeIter == g_Types.end()) return NULL;
|
||||
//if (typeIter == g_Types.end()) return NULL;
|
||||
MEASURETYPE current_type = g_meas_data[id].type;
|
||||
switch(current_type)
|
||||
{
|
||||
@ -217,23 +217,23 @@ UINT Update(UINT id)
|
||||
DWORD dwErr;
|
||||
GUID& intfGUID = pInterface->InterfaceGuid;
|
||||
dwErr = WlanQueryInterface( hClient, &intfGUID, wlan_intf_opcode_current_connection, NULL, &outsize, (PVOID*)&wlan_cattr, NULL );
|
||||
if( ERROR_SUCCESS != dwErr){
|
||||
if ( ERROR_SUCCESS != dwErr){
|
||||
return 0;
|
||||
}
|
||||
int retval = (int)wlan_cattr->wlanAssociationAttributes.wlanSignalQuality;
|
||||
if(wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr);
|
||||
if (wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr);
|
||||
return retval;
|
||||
|
||||
|
||||
//Transfer rates will go here
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
if(pInterface == NULL) return NULL;
|
||||
|
||||
if (pInterface == NULL) return NULL;
|
||||
|
||||
//Some variables for data manipulation in this function
|
||||
static WCHAR buffer[128];
|
||||
bool bNetList = false; //whether to return buffer or netlist
|
||||
@ -258,14 +258,14 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
UINT listMax = g_meas_data[id].listMax;
|
||||
|
||||
switch(current_type)
|
||||
{
|
||||
{
|
||||
case LIST:
|
||||
if(ERROR_SUCCESS != dwLErr){return L"Error";}
|
||||
|
||||
if (ERROR_SUCCESS != dwLErr){return L"Error";}
|
||||
|
||||
if (!g_meas_data[id].listInit){//Check if netlist has memory allocated already
|
||||
//Size of network name can be up to 64 chars, set to 80 to add room for delimiters
|
||||
g_meas_data[id].netlist = (WCHAR*)malloc( 80 * sizeof(WCHAR) * g_meas_data[id].listMax);
|
||||
if(g_meas_data[id].netlist == NULL){
|
||||
if (g_meas_data[id].netlist == NULL){
|
||||
WCHAR debug[256];
|
||||
wsprintf(debug, L"WifiStatus.dll: Unable to allocate memory for network list.");
|
||||
Log(buffer);
|
||||
@ -275,32 +275,32 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
}
|
||||
g_meas_data[id].listInit = true;
|
||||
}
|
||||
|
||||
|
||||
memset(g_meas_data[id].netlist,'\0', (80 * sizeof(WCHAR) * g_meas_data[id].listMax));
|
||||
memset(buffer,'\0',128);
|
||||
|
||||
|
||||
//Check all items in WLAN NETWORK LIST
|
||||
for(int i=0; i < (int)pwnl->dwNumberOfItems ; i++){
|
||||
if(printed == g_meas_data[id].listMax)
|
||||
for (int i=0; i < (int)pwnl->dwNumberOfItems ; i++){
|
||||
if (printed == g_meas_data[id].listMax)
|
||||
break;
|
||||
|
||||
|
||||
//SSID is in UCHAR, convert to WCHAR
|
||||
mbstowcs(buffer,(char*)pwnl->Network[i].dot11Ssid.ucSSID,pwnl->Network[i].dot11Ssid.uSSIDLength);
|
||||
|
||||
|
||||
//Prevent duplicates that result from profiles, check using SSID
|
||||
if((wcsstr(g_meas_data[id].netlist,buffer)== NULL)&&(_wcsicmp(L"", buffer) != 0)){
|
||||
if ((wcsstr(g_meas_data[id].netlist,buffer)== NULL)&&(_wcsicmp(L"", buffer) != 0)){
|
||||
printed++;
|
||||
if(listStyle > 0){
|
||||
if (listStyle > 0){
|
||||
wsprintf(g_meas_data[id].netlist,L"%s%s",g_meas_data[id].netlist,buffer);
|
||||
memset(buffer,'\0',128);
|
||||
if(listStyle == 1 || listStyle == 3){
|
||||
if (listStyle == 1 || listStyle == 3){
|
||||
//ADD PHY type
|
||||
wsprintf(buffer,L" @%s", getDot11str(pwnl->Network[i].dot11PhyTypes[0],4));
|
||||
wsprintf(buffer,L" @%s", getDot11str(pwnl->Network[i].dot11PhyTypes[0],4));
|
||||
}
|
||||
if(listStyle == 2 || listStyle == 3){
|
||||
if (listStyle == 2 || listStyle == 3){
|
||||
//ADD cipher and authentication
|
||||
wsprintf(buffer,L"%s (%s:%s)",buffer,getDot11str(pwnl->Network[i].dot11DefaultCipherAlgorithm,1)
|
||||
,getDot11str(pwnl->Network[i].dot11DefaultAuthAlgorithm,2));
|
||||
,getDot11str(pwnl->Network[i].dot11DefaultAuthAlgorithm,2));
|
||||
}
|
||||
}
|
||||
wsprintf(g_meas_data[id].netlist,L"%s%s\n",g_meas_data[id].netlist,buffer);
|
||||
@ -310,9 +310,9 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
}//end for
|
||||
bNetList=true;
|
||||
break;
|
||||
|
||||
|
||||
case SSID:
|
||||
if(ERROR_SUCCESS != dwCErr){
|
||||
if (ERROR_SUCCESS != dwCErr){
|
||||
bIntfError = true;
|
||||
break;
|
||||
}
|
||||
@ -321,9 +321,9 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
//If not connected yet add current status
|
||||
wcscat(buffer,getDot11str(wlan_cattr->isState,3));
|
||||
break;
|
||||
|
||||
|
||||
case PHY:
|
||||
if(ERROR_SUCCESS != dwCErr){
|
||||
if (ERROR_SUCCESS != dwCErr){
|
||||
bIntfError = true;
|
||||
break;
|
||||
}
|
||||
@ -331,7 +331,7 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
break;
|
||||
|
||||
case ENCRYPTION:
|
||||
if(ERROR_SUCCESS != dwCErr){
|
||||
if (ERROR_SUCCESS != dwCErr){
|
||||
bIntfError = true;
|
||||
break;
|
||||
}
|
||||
@ -339,27 +339,27 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
break;
|
||||
|
||||
case AUTH:
|
||||
if(ERROR_SUCCESS != dwCErr){
|
||||
if (ERROR_SUCCESS != dwCErr){
|
||||
bIntfError = true;
|
||||
break;
|
||||
}
|
||||
wcscpy(buffer,getDot11str(wlan_cattr->wlanSecurityAttributes.dot11AuthAlgorithm,2));
|
||||
wcscpy(buffer,getDot11str(wlan_cattr->wlanSecurityAttributes.dot11AuthAlgorithm,2));
|
||||
break;
|
||||
|
||||
default: //InfoType does not refer to a string measure
|
||||
bInvalidType= true;
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
if(wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr);
|
||||
if(pwnl!=NULL)WlanFreeMemory(pwnl);
|
||||
|
||||
if(bNetList)
|
||||
if (wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr);
|
||||
if (pwnl!=NULL)WlanFreeMemory(pwnl);
|
||||
|
||||
if (bNetList)
|
||||
return g_meas_data[id].netlist;
|
||||
if(bIntfError)
|
||||
if (bIntfError)
|
||||
return L"-1";
|
||||
else {
|
||||
if(bInvalidType)
|
||||
if (bInvalidType)
|
||||
return NULL;
|
||||
else
|
||||
return buffer;
|
||||
@ -367,13 +367,13 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
}
|
||||
|
||||
/*
|
||||
switches from winlanapi.h + SDK
|
||||
switches from winlanapi.h + SDK
|
||||
in: -DOT11 ENUM (converted to int)
|
||||
-type of ENUM (cipher=1, auth=2, status=3, phy=4, otherwise=error strings)
|
||||
-type of ENUM (cipher=1, auth=2, status=3, phy=4, otherwise=error strings)
|
||||
out: String to be returned by measure
|
||||
*/
|
||||
LPCTSTR getDot11str(int dot11enum,int type){
|
||||
if(type ==1){
|
||||
if (type ==1){
|
||||
switch(dot11enum){
|
||||
case DOT11_CIPHER_ALGO_NONE:
|
||||
return L"NONE";
|
||||
@ -390,7 +390,7 @@ LPCTSTR getDot11str(int dot11enum,int type){
|
||||
case DOT11_CIPHER_ALGO_WEP:
|
||||
return L"WEP";
|
||||
default:
|
||||
return L"???";
|
||||
return L"???";
|
||||
}
|
||||
}
|
||||
else if (type == 2){
|
||||
@ -410,10 +410,10 @@ LPCTSTR getDot11str(int dot11enum,int type){
|
||||
case DOT11_AUTH_ALGO_RSNA_PSK:
|
||||
return L"WPA2-Personal";
|
||||
default:
|
||||
return L"???";
|
||||
return L"???";
|
||||
}
|
||||
}
|
||||
else if(type==3){
|
||||
else if (type==3){
|
||||
switch(dot11enum){
|
||||
case wlan_interface_state_connected:
|
||||
return L"";
|
||||
@ -423,14 +423,14 @@ LPCTSTR getDot11str(int dot11enum,int type){
|
||||
return L"(connecting...)";
|
||||
}
|
||||
}
|
||||
else if(type==4){
|
||||
else if (type==4){
|
||||
switch(dot11enum){
|
||||
case dot11_phy_type_unknown:
|
||||
return L"???";
|
||||
case dot11_phy_type_dsss:
|
||||
return L"DSSS";
|
||||
case dot11_phy_type_erp:
|
||||
return L"802.11g";
|
||||
return L"802.11g";
|
||||
case dot11_phy_type_fhss:
|
||||
return L"FHSS";
|
||||
case dot11_phy_type_hrdsss:
|
||||
@ -476,11 +476,11 @@ void Finalize(HMODULE instance, UINT id)
|
||||
g_meas_data.erase(i1);
|
||||
}
|
||||
g_Instances--;
|
||||
if(hClient != NULL && g_Instances == 0){
|
||||
if (hClient != NULL && g_Instances == 0){
|
||||
WlanCloseHandle(hClient, NULL);
|
||||
hClient = NULL;
|
||||
}
|
||||
if(pIntfList != NULL && g_Instances == 0){
|
||||
if (pIntfList != NULL && g_Instances == 0){
|
||||
WlanFreeMemory(pIntfList);
|
||||
pIntfList = NULL;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "../../Library/DisableThreadLibraryCalls.h" // contains DllMain entry point
|
||||
|
||||
#define SAFE_RELEASE(punk) \
|
||||
if ((punk) != NULL) { (punk)->Release(); (punk) = NULL; }
|
||||
if ((punk) != NULL) { (punk)->Release(); (punk) = NULL; }
|
||||
|
||||
/* The exported functions */
|
||||
extern "C"
|
||||
@ -148,7 +148,7 @@ HRESULT RegisterDevice(PCWSTR devID)
|
||||
hr = S_FALSE;
|
||||
}
|
||||
UnInitCom();
|
||||
return hr;
|
||||
return hr;
|
||||
}
|
||||
|
||||
std::wstring GetDefaultID()
|
||||
@ -216,7 +216,7 @@ bool GetWin7AudioState(const VolumeAction action)
|
||||
|
||||
UINT GetIndex()
|
||||
{
|
||||
|
||||
|
||||
std::wstring id_default = L"";
|
||||
if (InitCom()) id_default = GetDefaultID();
|
||||
UnInitCom();
|
||||
@ -275,7 +275,7 @@ bool SetWin7Volume(UINT volume, int offset = 0)
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -294,7 +294,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
|
||||
UINT count;
|
||||
if (!pCollection || (S_OK != pCollection->GetCount(&count)))
|
||||
if (!pCollection || (S_OK != pCollection->GetCount(&count)))
|
||||
{
|
||||
UnInitCom();
|
||||
return 0;
|
||||
@ -302,10 +302,10 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
endpointIDs = std::vector<std::wstring>(count);
|
||||
|
||||
for (UINT i = 0; i < count; i++)
|
||||
{
|
||||
IMMDevice *pEndpoint = 0;
|
||||
{
|
||||
IMMDevice *pEndpoint = 0;
|
||||
|
||||
// Get pointer to endpoint number i.
|
||||
// Get pointer to endpoint number i.
|
||||
if (pCollection->Item(i, &pEndpoint) == S_OK)
|
||||
{
|
||||
// Get the endpoint ID string.
|
||||
@ -339,13 +339,13 @@ This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
double Update2(UINT id)
|
||||
{
|
||||
{
|
||||
GetWin7AudioState(GET_VOLUME);
|
||||
double volume = is_mute == TRUE ? -1.0 : floor(master_volume * 100.0 + 0.5); // rounding up at 0.5
|
||||
return volume > 100.0 ? 100.0 : volume;
|
||||
}
|
||||
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static WCHAR result[256];
|
||||
wsprintf(result, L"ERROR");
|
||||
|
@ -53,7 +53,7 @@ static std::map<UINT, windowData> g_Values;
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -107,7 +107,7 @@ This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
double Update2(UINT id)
|
||||
{
|
||||
{
|
||||
std::map<UINT, windowData>::iterator i = g_Values.find(id);
|
||||
if (i != g_Values.end())
|
||||
{
|
||||
@ -134,7 +134,7 @@ double Update2(UINT id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static WCHAR buffer[256];
|
||||
|
||||
|
@ -310,7 +310,7 @@ static bool updateCurrentTrack()
|
||||
IITArtworkPtr artwork;
|
||||
ITArtworkFormat artworkFormat;
|
||||
if (count > 0 &&
|
||||
SUCCEEDED(artworkCollection->get_Item(1, &artwork)) &&
|
||||
SUCCEEDED(artworkCollection->get_Item(1, &artwork)) &&
|
||||
SUCCEEDED(artwork->get_Format(&artworkFormat)))
|
||||
{
|
||||
_bstr_t path;
|
||||
@ -427,7 +427,7 @@ static void initEventHandler()
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
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:
|
||||
@ -469,7 +469,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
|
||||
const wchar_t* type = ReadConfigString(section, L"Command", L"");
|
||||
for(int i = 0; i < COMMAND_COUNT; i++)
|
||||
for (int i = 0; i < COMMAND_COUNT; i++)
|
||||
{
|
||||
if (CommandName[i] && type && _wcsicmp(CommandName[i], type) == 0)
|
||||
{
|
||||
@ -552,7 +552,7 @@ This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
#define BUFFER_SIZE 256
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
//Error Check
|
||||
static wchar_t buffer[BUFFER_SIZE];
|
||||
|
Reference in New Issue
Block a user