Add LogPropertyStore helper

This commit is contained in:
ge0rdi
2020-09-18 12:14:06 +02:00
parent d3bf4b6207
commit 935600a6d9
2 changed files with 34 additions and 0 deletions

View File

@@ -7,6 +7,8 @@
#include "stdafx.h"
#include "LogManager.h"
#include "ResourceHelper.h"
#include "ComHelper.h"
#include <propvarutil.h>
int g_LogCategories;
static FILE *g_LogFile;
@@ -51,3 +53,31 @@ void LogMessage( const wchar_t *text, ... )
fflush(g_LogFile);
}
void LogPropertyStore(TLogCategory category, IPropertyStore* store)
{
if (!store)
return;
DWORD count = 0;
store->GetCount(&count);
for (DWORD i = 0; i < count; i++)
{
PROPERTYKEY key{};
store->GetAt(i, &key);
PROPVARIANT val;
PropVariantInit(&val);
store->GetValue(key, &val);
CComString valueStr;
PropVariantToStringAlloc(val, &valueStr);
PropVariantClear(&val);
wchar_t guidStr[100]{};
StringFromGUID2(key.fmtid, guidStr, _countof(guidStr));
LOG_MENU(category, L"Property: {%s, %u} = %s", guidStr, key.pid, valueStr ? valueStr : L"???");
}
}

View File

@@ -4,6 +4,8 @@
#pragma once
#include <propsys.h>
// LogManager.h - logging functionality (for debugging)
// Logs different events in the start menu
// Turn it on by setting the LogLevel setting in the registry
@@ -33,3 +35,5 @@ void CloseLog( void );
void LogMessage( const wchar_t *text, ... );
#define STARTUP_LOG L"Software\\OpenShell\\StartMenu\\Settings|LogStartup|%LOCALAPPDATA%\\OpenShell\\StartupLog.txt"
void LogPropertyStore(TLogCategory category, IPropertyStore* store);