i did this stuff in a haze and don't even remember most of it, i don't think it works yet
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
/* Headers */
|
/* Headers */
|
||||||
#include "progmgr.h"
|
#include "progmgr.h"
|
||||||
|
#include "group.h"
|
||||||
#include "registry.h"
|
#include "registry.h"
|
||||||
// #define WIN32_LEAN_AND_MEAN
|
// #define WIN32_LEAN_AND_MEAN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
@@ -110,6 +111,51 @@ BOOL IsProgMgrDefaultShell()
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* * * *\
|
||||||
|
SaveGroupToRegistry -
|
||||||
|
Saves a group structure to registry.
|
||||||
|
RETURNS -
|
||||||
|
RCE_* configuration error value
|
||||||
|
\* * * */
|
||||||
|
DWORD SaveGroupToRegistry(_In_ PGROUP pg)
|
||||||
|
{
|
||||||
|
DWORD dwConfigStatus = RCE_SUCCESS;
|
||||||
|
|
||||||
|
// If the pointer is invalid then fail out
|
||||||
|
if (pg == NULL)
|
||||||
|
return RCE_FAILURE;
|
||||||
|
|
||||||
|
if (!RegSetValueEx(hKeyProgramGroups, pg->szGroupName, 0, REG_BINARY,
|
||||||
|
(const BYTE*)pg, (sizeof(*pg) + sizeof(ITEM) * pg->cItems)) == ERROR_SUCCESS)
|
||||||
|
dwConfigStatus = dwConfigStatus && RCE_GROUPS;
|
||||||
|
|
||||||
|
return dwConfigStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* * * *\
|
||||||
|
LoadGroupFromRegistry -
|
||||||
|
Loads a group structure from the registry.
|
||||||
|
RETURNS -
|
||||||
|
RCE_* configuration error value
|
||||||
|
\* * * */
|
||||||
|
DWORD LoadGroupFromRegistry(_Inout_ PGROUP pg, _Out_ DWORD dwBufferSize)
|
||||||
|
{
|
||||||
|
DWORD dwConfigStatus = RCE_SUCCESS;
|
||||||
|
DWORD dwBufferSize = (sizeof(*pg) + sizeof(ITEM) * pg->cItems);
|
||||||
|
DWORD dwType = REG_BINARY;
|
||||||
|
|
||||||
|
// If the pointer is invalid then fail out
|
||||||
|
if (pg == NULL)
|
||||||
|
return RCE_FAILURE;
|
||||||
|
|
||||||
|
// Load window position
|
||||||
|
if (!RegQueryValueEx(hKeyProgramGroups, pg->szGroupName, 0, &dwType,
|
||||||
|
(LPBYTE)pg, &dwBufferSize) == ERROR_SUCCESS)
|
||||||
|
dwConfigStatus = dwConfigStatus && RCE_POSITION;
|
||||||
|
|
||||||
|
return dwConfigStatus;
|
||||||
|
}
|
||||||
|
|
||||||
/* * * *\
|
/* * * *\
|
||||||
SaveConfig -
|
SaveConfig -
|
||||||
Finds and collapses all settings
|
Finds and collapses all settings
|
||||||
@@ -119,7 +165,7 @@ BOOL IsProgMgrDefaultShell()
|
|||||||
\* * * */
|
\* * * */
|
||||||
DWORD SaveConfig(BOOL bSettings, BOOL bPos, BOOL bGroups)
|
DWORD SaveConfig(BOOL bSettings, BOOL bPos, BOOL bGroups)
|
||||||
{
|
{
|
||||||
DWORD bConfigStatus = RCE_SUCCESS;
|
DWORD dwConfigStatus = RCE_SUCCESS;
|
||||||
|
|
||||||
if (bSettings)
|
if (bSettings)
|
||||||
{
|
{
|
||||||
@@ -135,7 +181,7 @@ DWORD SaveConfig(BOOL bSettings, BOOL bPos, BOOL bGroups)
|
|||||||
|
|
||||||
if (!RegSetValueEx(hKeySettings, pszSettingsMask, 0, REG_DWORD,
|
if (!RegSetValueEx(hKeySettings, pszSettingsMask, 0, REG_DWORD,
|
||||||
(const BYTE*)&dwSettingsMask, sizeof(dwSettingsMask)) == ERROR_SUCCESS)
|
(const BYTE*)&dwSettingsMask, sizeof(dwSettingsMask)) == ERROR_SUCCESS)
|
||||||
bConfigStatus = bConfigStatus && RCE_SETTINGS;
|
dwConfigStatus = dwConfigStatus && RCE_SETTINGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bPos)
|
if (bPos)
|
||||||
@@ -150,7 +196,7 @@ DWORD SaveConfig(BOOL bSettings, BOOL bPos, BOOL bGroups)
|
|||||||
|
|
||||||
if (!RegSetValueEx(hKeySettings, pszSettingsWindow, 0, REG_BINARY,
|
if (!RegSetValueEx(hKeySettings, pszSettingsWindow, 0, REG_BINARY,
|
||||||
(const BYTE*)&rcWindow, sizeof(rcWindow)) == ERROR_SUCCESS)
|
(const BYTE*)&rcWindow, sizeof(rcWindow)) == ERROR_SUCCESS)
|
||||||
bConfigStatus = bConfigStatus && RCE_POSITION;
|
dwConfigStatus = dwConfigStatus && RCE_POSITION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bGroups)
|
if (bGroups)
|
||||||
@@ -158,10 +204,10 @@ DWORD SaveConfig(BOOL bSettings, BOOL bPos, BOOL bGroups)
|
|||||||
// TODO: Get list of groups, iterate through,
|
// TODO: Get list of groups, iterate through,
|
||||||
// save each one as an individual subkey based
|
// save each one as an individual subkey based
|
||||||
// on the name of the group
|
// on the name of the group
|
||||||
bConfigStatus = bConfigStatus && RCE_GROUPS;
|
dwConfigStatus = dwConfigStatus && RCE_GROUPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bConfigStatus;
|
return dwConfigStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* * * *\
|
/* * * *\
|
||||||
@@ -173,17 +219,17 @@ DWORD SaveConfig(BOOL bSettings, BOOL bPos, BOOL bGroups)
|
|||||||
\* * * */
|
\* * * */
|
||||||
DWORD LoadConfig(BOOL bSettings, BOOL bPos, BOOL bGroups)
|
DWORD LoadConfig(BOOL bSettings, BOOL bPos, BOOL bGroups)
|
||||||
{
|
{
|
||||||
DWORD bConfigStatus = RCE_SUCCESS;
|
DWORD dwConfigStatus = RCE_SUCCESS;
|
||||||
DWORD dwType;
|
|
||||||
|
|
||||||
if (bSettings)
|
if (bSettings)
|
||||||
{
|
{
|
||||||
DWORD dwBufferSize = sizeof(dwSettingsMask);
|
DWORD dwBufferSize = sizeof(dwSettingsMask);
|
||||||
|
DWORD dwType = REG_DWORD;
|
||||||
|
|
||||||
// Load settings bitmask
|
// Load settings bitmask
|
||||||
if (!RegQueryValueEx(hKeySettings, pszSettingsMask, 0, &dwType,
|
if (!RegQueryValueEx(hKeySettings, pszSettingsMask, 0, &dwType,
|
||||||
(LPBYTE)&dwSettingsMask, &dwBufferSize) == ERROR_SUCCESS)
|
(LPBYTE)&dwSettingsMask, &dwBufferSize) == ERROR_SUCCESS)
|
||||||
bConfigStatus = bConfigStatus && RCE_SETTINGS;
|
dwConfigStatus = dwConfigStatus && RCE_SETTINGS;
|
||||||
|
|
||||||
// Apply bitmask to booleans
|
// Apply bitmask to booleans
|
||||||
bAutoArrange = (dwSettingsMask & PMS_AUTOARRANGE);
|
bAutoArrange = (dwSettingsMask & PMS_AUTOARRANGE);
|
||||||
@@ -196,18 +242,19 @@ DWORD LoadConfig(BOOL bSettings, BOOL bPos, BOOL bGroups)
|
|||||||
if (bPos)
|
if (bPos)
|
||||||
{
|
{
|
||||||
DWORD dwRectBufferSize = sizeof(rcMainWindow);
|
DWORD dwRectBufferSize = sizeof(rcMainWindow);
|
||||||
|
DWORD dwType = REG_BINARY;
|
||||||
|
|
||||||
// Load window position
|
// Load window position
|
||||||
if (!RegQueryValueEx(hKeySettings, pszSettingsWindow, 0, &dwType,
|
if (!RegQueryValueEx(hKeySettings, pszSettingsWindow, 0, &dwType,
|
||||||
(LPBYTE)&rcMainWindow, &dwRectBufferSize) == ERROR_SUCCESS)
|
(LPBYTE)&rcMainWindow, &dwRectBufferSize) == ERROR_SUCCESS)
|
||||||
bConfigStatus = bConfigStatus && RCE_POSITION;
|
dwConfigStatus = dwConfigStatus && RCE_POSITION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bGroups)
|
if (bGroups)
|
||||||
{
|
{
|
||||||
// TODO: this is unbearable
|
// TODO: this is unbearable
|
||||||
bConfigStatus = bConfigStatus && RCE_GROUPS;
|
dwConfigStatus = dwConfigStatus && RCE_GROUPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bConfigStatus;
|
return dwConfigStatus;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,9 +22,10 @@
|
|||||||
#define PROGMGR_KEY L"Software\\Vortesys\\Program Manager II"
|
#define PROGMGR_KEY L"Software\\Vortesys\\Program Manager II"
|
||||||
// Registry configuration error values (DWORD)
|
// Registry configuration error values (DWORD)
|
||||||
#define RCE_SUCCESS 0x0000000
|
#define RCE_SUCCESS 0x0000000
|
||||||
#define RCE_SETTINGS 0x0000001
|
#define RCE_FAILURE 0x0000001
|
||||||
#define RCE_POSITION 0x0000002
|
#define RCE_SETTINGS 0x0000002
|
||||||
#define RCE_GROUPS 0x0000004
|
#define RCE_POSITION 0x0000004
|
||||||
|
#define RCE_GROUPS 0x0000008
|
||||||
// Settings values (DWORD)
|
// Settings values (DWORD)
|
||||||
#define PMS_AUTOARRANGE 0x00000001
|
#define PMS_AUTOARRANGE 0x00000001
|
||||||
#define PMS_MINONRUN 0x00000002
|
#define PMS_MINONRUN 0x00000002
|
||||||
@@ -48,5 +49,9 @@ extern RECT rcMainWindow;
|
|||||||
/* Function Prototypes */
|
/* Function Prototypes */
|
||||||
BOOL InitializeRegistryKeys(VOID);
|
BOOL InitializeRegistryKeys(VOID);
|
||||||
BOOL IsProgMgrDefaultShell(VOID);
|
BOOL IsProgMgrDefaultShell(VOID);
|
||||||
DWORD LoadConfig(BOOL bSettings, BOOL bPos, BOOL bGroups);
|
// Groups
|
||||||
|
DWORD SaveGroupToRegistry(_In_ PGROUP pg);
|
||||||
|
DWORD LoadGroupFromRegistry(_Inout_ PGROUP pg, _Out_ DWORD dwBufferSize);
|
||||||
|
// Settings
|
||||||
DWORD SaveConfig(BOOL bSettings, BOOL bPos, BOOL bGroups);
|
DWORD SaveConfig(BOOL bSettings, BOOL bPos, BOOL bGroups);
|
||||||
|
DWORD LoadConfig(BOOL bSettings, BOOL bPos, BOOL bGroups);
|
||||||
|
|||||||
Reference in New Issue
Block a user