snow flurry
69476552e8
I wish I didn't end up doing this all at once, but ah well. Quick rundown: - CommonCfg contains config/registry functions shared between Grabby and GrbyCfg. - GrbyCfg provides a dialog for configuring Grabby. git-svn-id: svn://vcs.sdm.2ki.xyz/Grabby/trunk@16 27729192-006e-004d-b9b5-06fbd0ef7001
65 lines
1.2 KiB
C
65 lines
1.2 KiB
C
#include "stdafx.h"
|
|
|
|
static BOOL
|
|
UploadConfigCb(HKEY hKey,
|
|
LPTSTR szValName,
|
|
DWORD dwValSize,
|
|
DWORD dwValType,
|
|
PVOID pData)
|
|
{
|
|
UploadConfig *ucfg = pData;
|
|
if (!ucfg) return FALSE;
|
|
|
|
CopyIfMatch(hKey, ucfg,
|
|
Name, REG_SZ)
|
|
else CopyIfMatch(hKey, ucfg,
|
|
URL, REG_SZ)
|
|
else CopyIfMatch(hKey, ucfg,
|
|
Method, REG_SZ)
|
|
else CopyIfMatch(hKey, ucfg,
|
|
Username, REG_SZ)
|
|
else CopyIfMatch(hKey, ucfg,
|
|
Password, REG_SZ)
|
|
else CopyIfMatch(hKey, ucfg,
|
|
HTTPAuthMethod, REG_DWORD)
|
|
else CopyIfMatch(hKey, ucfg,
|
|
Headers, REG_MULTI_SZ)
|
|
else CopyIfMatch(hKey, ucfg,
|
|
Parameters, REG_MULTI_SZ)
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
UploadConfig *
|
|
GetUploadConfig(void)
|
|
{
|
|
|
|
HKEY hkUploadKey = NULL;
|
|
HANDLE hHeap = GetProcessHeap();
|
|
LONG lRes;
|
|
UploadConfig *ucfg = HeapAlloc(hHeap,
|
|
HEAP_ZERO_MEMORY,
|
|
sizeof(UploadConfig));
|
|
|
|
if (!ucfg) return NULL;
|
|
|
|
// TODO: defaults?
|
|
lRes = RegOpenKeyEx(HKEY_CURRENT_USER,
|
|
_T(ROOT_KEYNAME "\\Upload"),
|
|
0,
|
|
KEY_READ,
|
|
&hkUploadKey);
|
|
|
|
if (lRes) {
|
|
SetLastError(lRes);
|
|
HeapFree(hHeap, 0, ucfg);
|
|
return NULL;
|
|
}
|
|
|
|
if (!RegGetAllValues(hkUploadKey, UploadConfigCb, ucfg)) {
|
|
HeapFree(hHeap, 0, ucfg);
|
|
return NULL;
|
|
}
|
|
|
|
return ucfg;
|
|
} |