2 * PROJECT: ReactOS Local Spooler
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Various tools
5 * COPYRIGHT: Copyright 2015-2017 Colin Finck (colin@reactos.org)
11 * @name AllocAndRegQueryWSZ
13 * Queries a REG_SZ value in the registry, allocates memory for it and returns a buffer containing the value.
14 * You have to free this buffer using DllFreeSplMem.
17 * HKEY variable of the key opened with RegOpenKeyExW.
19 * @param pwszValueName
20 * Name of the REG_SZ value to query.
23 * Pointer to the buffer containing the value or NULL in case of failure.
26 AllocAndRegQueryWSZ(HKEY hKey
, PCWSTR pwszValueName
)
32 // Determine the size of the required buffer.
33 lStatus
= RegQueryValueExW(hKey
, pwszValueName
, NULL
, NULL
, NULL
, &cbNeeded
);
34 if (lStatus
!= ERROR_SUCCESS
)
36 ERR("RegQueryValueExW failed with status %ld!\n", lStatus
);
41 pwszValue
= DllAllocSplMem(cbNeeded
);
44 ERR("DllAllocSplMem failed!\n");
48 // Now get the actual value.
49 lStatus
= RegQueryValueExW(hKey
, pwszValueName
, NULL
, NULL
, (PBYTE
)pwszValue
, &cbNeeded
);
50 if (lStatus
!= ERROR_SUCCESS
)
52 ERR("RegQueryValueExW failed with status %ld!\n", lStatus
);
53 DllFreeSplMem(pwszValue
);
61 DuplicateDevMode(PDEVMODEW pInput
)
65 // Allocate a buffer for this DevMode.
66 pOutput
= DllAllocSplMem(pInput
->dmSize
+ pInput
->dmDriverExtra
);
69 ERR("DllAllocSplMem failed!\n");
74 CopyMemory(pOutput
, pInput
, pInput
->dmSize
+ pInput
->dmDriverExtra
);