RegCreatekeyEx与UNICODE的问题?
MSDN中对RegCreatekeyEx的原型是这样描述的:
LONG RegCreateKeyEx(
HKEY hKey, // handle to an open key
LPCTSTR lpSubKey, // address of subkey name
DWORD Reserved, // reserved
LPTSTR lpClass, // address of class string
DWORD dwOptions, // special options flag
REGSAM samDesired, // desired security access
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
// address of key security structure
PHKEY phkResult, // address of buffer for opened handle
LPDWORD lpdwDisposition // address of disposition value buffer
);
winreg.h中的定义:
RegCreateKeyExW (
HKEY hKey,
LPCWSTR lpSubKey,
DWORD Reserved,
LPWSTR lpClass,
DWORD dwOptions,
REGSAM samDesired,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
PHKEY phkResult,
LPDWORD lpdwDisposition
);
...
#define RegCreateKeyEx RegCreateKeyExW
在VC6中编译时出现错误,
error C2664: 'RegCreateKeyExW' : cannot convert parameter 2 from 'const char *' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
编译时使用UNICODE,预处理选项:
WIN32,_DEBUG,_WINDOWS,_USRDLL,_UNICODE
编译选项:
nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /Fp"DebugU/AnalyzeIE.pch" /Yu"stdafx.h" /Fo"DebugU/" /Fd"DebugU/" /FD /GZ /c
如果不用UNICODE,则没有编译错误。
请问这是什么原因?如何在UNICODE下编译通过?