As Raymond Chen said in a comment, you can use two separate overloaded functions: one for Ansi, one for Unicode:
namespace Reg
{
LONG WINAPI CreateKey(
_In_ HKEY hKey,
_In_ LPCSTR lpSubKey,
_In_ REGSAM samDesired,
_Out_ PHKEY phkResult
)
{
return RegCreateKeyExA(hKey,
lpSubKey,
0, NULL,
REG_OPTION_NON_VOLATILE,
samDesired,
NULL,
phkResult,
NULL);
}
LONG WINAPI CreateKey(
_In_ HKEY hKey,
_In_ LPCWSTR lpSubKey,
_In_ REGSAM samDesired,
_Out_ PHKEY phkResult
)
{
return RegCreateKeyExW(hKey,
lpSubKey,
0, NULL,
REG_OPTION_NON_VOLATILE,
samDesired,
NULL,
phkResult,
NULL);
}
}
Or, as rubenvb suggested, just forget about the Ansi function in general, focus only on Unicode:
namespace Reg
{
LONG WINAPI CreateKey(
_In_ HKEY hKey,
_In_ LPCWSTR lpSubKey,
_In_ REGSAM samDesired,
_Out_ PHKEY phkResult
)
{
return RegCreateKeyExW(hKey,
lpSubKey,
0, NULL,
REG_OPTION_NON_VOLATILE,
samDesired,
NULL,
phkResult,
NULL);
}
}