atl: Use wide-char string literals.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2020-10-07 00:51:58 +02:00 committed by Alexandre Julliard
parent 2a2001b300
commit 568c32f381
4 changed files with 44 additions and 74 deletions

View File

@ -123,7 +123,6 @@ HRESULT WINAPI AtlUnmarshalPtr(IStream *stm, const IID *iid, IUnknown **ppUnk)
*/ */
HDC WINAPI AtlCreateTargetDC( HDC hdc, DVTARGETDEVICE *dv ) HDC WINAPI AtlCreateTargetDC( HDC hdc, DVTARGETDEVICE *dv )
{ {
static const WCHAR displayW[] = {'d','i','s','p','l','a','y',0};
const WCHAR *driver = NULL, *device = NULL, *port = NULL; const WCHAR *driver = NULL, *device = NULL, *port = NULL;
DEVMODEW *devmode = NULL; DEVMODEW *devmode = NULL;
@ -139,7 +138,7 @@ HDC WINAPI AtlCreateTargetDC( HDC hdc, DVTARGETDEVICE *dv )
else else
{ {
if (hdc) return hdc; if (hdc) return hdc;
driver = displayW; driver = L"display";
} }
return CreateDCW( driver, device, port, devmode ); return CreateDCW( driver, device, port, devmode );
} }
@ -342,12 +341,10 @@ HRESULT WINAPI AtlLoadTypeLib(HINSTANCE inst, LPCOLESTR lpszIndex,
WCHAR *path; WCHAR *path;
HRESULT hres; HRESULT hres;
static const WCHAR tlb_extW[] = {'.','t','l','b',0};
TRACE("(%p %s %p %p)\n", inst, debugstr_w(lpszIndex), pbstrPath, ppTypeLib); TRACE("(%p %s %p %p)\n", inst, debugstr_w(lpszIndex), pbstrPath, ppTypeLib);
index_len = lpszIndex ? lstrlenW(lpszIndex) : 0; index_len = lpszIndex ? lstrlenW(lpszIndex) : 0;
path = heap_alloc((MAX_PATH+index_len)*sizeof(WCHAR) + sizeof(tlb_extW)); path = heap_alloc((MAX_PATH+index_len)*sizeof(WCHAR) + sizeof(L".tlb"));
if(!path) if(!path)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
@ -367,7 +364,7 @@ HRESULT WINAPI AtlLoadTypeLib(HINSTANCE inst, LPCOLESTR lpszIndex,
for(ptr = path+path_len-1; ptr > path && *ptr != '\\' && *ptr != '.'; ptr--); for(ptr = path+path_len-1; ptr > path && *ptr != '\\' && *ptr != '.'; ptr--);
if(*ptr != '.') if(*ptr != '.')
ptr = path+path_len; ptr = path+path_len;
memcpy(ptr, tlb_extW, sizeof(tlb_extW)); lstrcpyW(ptr, L".tlb");
hres = LoadTypeLib(path, &typelib); hres = LoadTypeLib(path, &typelib);
} }
@ -781,20 +778,15 @@ HRESULT WINAPI AtlRegisterClassCategoriesHelper(REFCLSID clsid, const struct _AT
} }
if(!reg) { if(!reg) {
WCHAR reg_path[256] = {'C','L','S','I','D','\\'}, *ptr = reg_path+6; WCHAR reg_path[256] = L"CLSID\\", *ptr = reg_path+6;
static const WCHAR implemented_catW[] =
{'I','m','p','l','e','m','e','n','t','e','d',' ','C','a','t','e','g','o','r','i','e','s',0};
static const WCHAR required_catW[] =
{'R','e','q','u','i','r','e','d',' ','C','a','t','e','g','o','r','i','e','s',0};
ptr += StringFromGUID2(clsid, ptr, 64)-1; ptr += StringFromGUID2(clsid, ptr, 64)-1;
*ptr++ = '\\'; *ptr++ = '\\';
memcpy(ptr, implemented_catW, sizeof(implemented_catW)); lstrcpyW(ptr, L"Implemented Categories");
RegDeleteKeyW(HKEY_CLASSES_ROOT, reg_path); RegDeleteKeyW(HKEY_CLASSES_ROOT, reg_path);
memcpy(ptr, required_catW, sizeof(required_catW)); lstrcpyW(ptr, L"Required Categories");
RegDeleteKeyW(HKEY_CLASSES_ROOT, reg_path); RegDeleteKeyW(HKEY_CLASSES_ROOT, reg_path);
} }

View File

@ -55,8 +55,6 @@ typedef struct IOCS {
BOOL fActive, fInPlace, fWindowless; BOOL fActive, fInPlace, fWindowless;
} IOCS; } IOCS;
static const WCHAR wine_atl_iocsW[] = {'_','_','W','I','N','E','_','A','T','L','_','I','O','C','S','\0'};
/********************************************************************** /**********************************************************************
* AtlAxWin class window procedure * AtlAxWin class window procedure
*/ */
@ -90,20 +88,20 @@ BOOL WINAPI AtlAxWinInit(void)
WNDCLASSEXW wcex; WNDCLASSEXW wcex;
#if _ATL_VER <= _ATL_VER_30 #if _ATL_VER <= _ATL_VER_30
#define ATL_NAME_SUFFIX 0 #define ATL_NAME_SUFFIX
#elif _ATL_VER == _ATL_VER_80 #elif _ATL_VER == _ATL_VER_80
#define ATL_NAME_SUFFIX '8','0',0 #define ATL_NAME_SUFFIX L"80"
#elif _ATL_VER == _ATL_VER_90 #elif _ATL_VER == _ATL_VER_90
#define ATL_NAME_SUFFIX '9','0',0 #define ATL_NAME_SUFFIX L"90"
#elif _ATL_VER == _ATL_VER_100 #elif _ATL_VER == _ATL_VER_100
#define ATL_NAME_SUFFIX '1','0','0',0 #define ATL_NAME_SUFFIX L"100"
#elif _ATL_VER == _ATL_VER_110 #elif _ATL_VER == _ATL_VER_110
#define ATL_NAME_SUFFIX '1','1','0',0 #define ATL_NAME_SUFFIX L"110"
#else #else
#error Unsupported version #error Unsupported version
#endif #endif
static const WCHAR AtlAxWinW[] = {'A','t','l','A','x','W','i','n',ATL_NAME_SUFFIX}; static const WCHAR AtlAxWinW[] = L"AtlAxWin" ATL_NAME_SUFFIX;
FIXME("version %04x semi-stub\n", _ATL_VER); FIXME("version %04x semi-stub\n", _ATL_VER);
@ -127,7 +125,7 @@ BOOL WINAPI AtlAxWinInit(void)
return FALSE; return FALSE;
if(_ATL_VER > _ATL_VER_30) { if(_ATL_VER > _ATL_VER_30) {
static const WCHAR AtlAxWinLicW[] = {'A','t','l','A','x','W','i','n','L','i','c',ATL_NAME_SUFFIX}; static const WCHAR AtlAxWinLicW[] = L"AtlAxWinLic" ATL_NAME_SUFFIX;
wcex.lpszClassName = AtlAxWinLicW; wcex.lpszClassName = AtlAxWinLicW;
if ( !RegisterClassExW( &wcex ) ) if ( !RegisterClassExW( &wcex ) )
@ -152,7 +150,7 @@ static HRESULT IOCS_Detach( IOCS *This ) /* remove subclassing */
if ( This->hWnd ) if ( This->hWnd )
{ {
SetWindowLongPtrW( This->hWnd, GWLP_WNDPROC, (ULONG_PTR) This->OrigWndProc ); SetWindowLongPtrW( This->hWnd, GWLP_WNDPROC, (ULONG_PTR) This->OrigWndProc );
RemovePropW( This->hWnd, wine_atl_iocsW); RemovePropW( This->hWnd, L"__WINE_ATL_IOCS" );
This->hWnd = NULL; This->hWnd = NULL;
} }
if ( This->control ) if ( This->control )
@ -906,7 +904,7 @@ static LRESULT IOCS_OnWndProc( IOCS *This, HWND hWnd, UINT uMsg, WPARAM wParam,
static LRESULT CALLBACK AtlHost_wndproc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam ) static LRESULT CALLBACK AtlHost_wndproc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
{ {
IOCS *This = (IOCS*) GetPropW( hWnd, wine_atl_iocsW ); IOCS *This = (IOCS*) GetPropW( hWnd, L"__WINE_ATL_IOCS" );
return IOCS_OnWndProc( This, hWnd, wMsg, wParam, lParam ); return IOCS_OnWndProc( This, hWnd, wMsg, wParam, lParam );
} }
@ -915,7 +913,7 @@ static HRESULT IOCS_Attach( IOCS *This, HWND hWnd, IUnknown *pUnkControl ) /* su
This->hWnd = hWnd; This->hWnd = hWnd;
IUnknown_QueryInterface( pUnkControl, &IID_IOleObject, (void**)&This->control ); IUnknown_QueryInterface( pUnkControl, &IID_IOleObject, (void**)&This->control );
IOleObject_SetClientSite( This->control, &This->IOleClientSite_iface ); IOleObject_SetClientSite( This->control, &This->IOleClientSite_iface );
SetPropW( hWnd, wine_atl_iocsW, This ); SetPropW( hWnd, L"__WINE_ATL_IOCS", This );
This->OrigWndProc = (WNDPROC)SetWindowLongPtrW( hWnd, GWLP_WNDPROC, (ULONG_PTR) AtlHost_wndproc ); This->OrigWndProc = (WNDPROC)SetWindowLongPtrW( hWnd, GWLP_WNDPROC, (ULONG_PTR) AtlHost_wndproc );
return S_OK; return S_OK;
@ -924,9 +922,8 @@ static HRESULT IOCS_Attach( IOCS *This, HWND hWnd, IUnknown *pUnkControl ) /* su
static HRESULT IOCS_Init( IOCS *This ) static HRESULT IOCS_Init( IOCS *This )
{ {
RECT rect; RECT rect;
static const WCHAR AXWIN[] = {'A','X','W','I','N',0};
IOleObject_SetHostNames( This->control, AXWIN, AXWIN ); IOleObject_SetHostNames( This->control, L"AXWIN", L"AXWIN" );
GetClientRect( This->hWnd, &rect ); GetClientRect( This->hWnd, &rect );
IOCS_OnSize( This, &rect ); IOCS_OnSize( This, &rect );
@ -1000,7 +997,6 @@ enum content
static enum content get_content_type(LPCOLESTR name, CLSID *control_id) static enum content get_content_type(LPCOLESTR name, CLSID *control_id)
{ {
static const WCHAR mshtml_prefixW[] = {'m','s','h','t','m','l',':',0};
WCHAR new_urlW[MAX_PATH]; WCHAR new_urlW[MAX_PATH];
DWORD size = MAX_PATH; DWORD size = MAX_PATH;
@ -1021,7 +1017,7 @@ static enum content get_content_type(LPCOLESTR name, CLSID *control_id)
return IsURL; return IsURL;
} }
if (!wcsnicmp(name, mshtml_prefixW, 7)) if (!wcsnicmp(name, L"mshtml:", 7))
{ {
FIXME("mshtml prefix not implemented\n"); FIXME("mshtml prefix not implemented\n");
*control_id = CLSID_WebBrowser; *control_id = CLSID_WebBrowser;
@ -1266,8 +1262,7 @@ static LPDLGTEMPLATEW AX_ConvertDialogTemplate(LPCDLGTEMPLATEW src_tmpl)
src += lstrlenW(src) + 1; /* title */ src += lstrlenW(src) + 1; /* title */
if ( GET_WORD(tmp) == '{' ) /* all this mess created because of this line */ if ( GET_WORD(tmp) == '{' ) /* all this mess created because of this line */
{ {
static const WCHAR AtlAxWin[] = {'A','t','l','A','x','W','i','n', 0}; PUT_BLOCK(L"AtlAxWin", ARRAY_SIZE(L"AtlAxWin"));
PUT_BLOCK(AtlAxWin, ARRAY_SIZE(AtlAxWin));
PUT_BLOCK(tmp, lstrlenW(tmp)+1); PUT_BLOCK(tmp, lstrlenW(tmp)+1);
} else } else
PUT_BLOCK(tmp, src-tmp); PUT_BLOCK(tmp, src-tmp);
@ -1373,7 +1368,7 @@ HRESULT WINAPI AtlAxGetHost(HWND hWnd, IUnknown **host)
*host = NULL; *host = NULL;
This = (IOCS*) GetPropW( hWnd, wine_atl_iocsW ); This = (IOCS*) GetPropW( hWnd, L"__WINE_ATL_IOCS" );
if ( !This ) if ( !This )
{ {
WARN("No container attached to %p\n", hWnd ); WARN("No container attached to %p\n", hWnd );
@ -1395,7 +1390,7 @@ HRESULT WINAPI AtlAxGetControl(HWND hWnd, IUnknown **pUnk)
*pUnk = NULL; *pUnk = NULL;
This = (IOCS*) GetPropW( hWnd, wine_atl_iocsW ); This = (IOCS*) GetPropW( hWnd, L"__WINE_ATL_IOCS" );
if ( !This || !This->control ) if ( !This || !This->control )
{ {
WARN("No control attached to %p\n", hWnd ); WARN("No control attached to %p\n", hWnd );

View File

@ -32,27 +32,20 @@ static const struct {
WCHAR name[22]; WCHAR name[22];
HKEY key; HKEY key;
} root_keys[] = { } root_keys[] = {
{{'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0}, {L"HKEY_CLASSES_ROOT", HKEY_CLASSES_ROOT},
HKEY_CLASSES_ROOT}, {L"HKEY_CURRENT_USER", HKEY_CURRENT_USER},
{{'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0}, {L"HKEY_LOCAL_MACHINE", HKEY_LOCAL_MACHINE},
HKEY_CURRENT_USER}, {L"HKEY_USERS", HKEY_USERS},
{{'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0}, {L"HKEY_PERFORMANCE_DATA", HKEY_PERFORMANCE_DATA},
HKEY_LOCAL_MACHINE}, {L"HKEY_DYN_DATA", HKEY_DYN_DATA},
{{'H','K','E','Y','_','U','S','E','R','S',0}, {L"HKEY_CURRENT_CONFIG", HKEY_CURRENT_CONFIG},
HKEY_USERS}, {L"HKCR", HKEY_CLASSES_ROOT},
{{'H','K','E','Y','_','P','E','R','F','O','R','M','A','N','C','E','_','D','A','T','A',0}, {L"HKCU", HKEY_CURRENT_USER},
HKEY_PERFORMANCE_DATA}, {L"HKLM", HKEY_LOCAL_MACHINE},
{{'H','K','E','Y','_','D','Y','N','_','D','A','T','A',0}, {L"HKU", HKEY_USERS},
HKEY_DYN_DATA}, {L"HKPD", HKEY_PERFORMANCE_DATA},
{{'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0}, {L"HKDD", HKEY_DYN_DATA},
HKEY_CURRENT_CONFIG}, {L"HKCC", HKEY_CURRENT_CONFIG}
{{'H','K','C','R',0}, HKEY_CLASSES_ROOT},
{{'H','K','C','U',0}, HKEY_CURRENT_USER},
{{'H','K','L','M',0}, HKEY_LOCAL_MACHINE},
{{'H','K','U',0}, HKEY_USERS},
{{'H','K','P','D',0}, HKEY_PERFORMANCE_DATA},
{{'H','K','D','D',0}, HKEY_DYN_DATA},
{{'H','K','C','C',0}, HKEY_CURRENT_CONFIG}
}; };
typedef struct rep_list_str { typedef struct rep_list_str {
@ -150,7 +143,6 @@ static HRESULT do_preprocess(const Registrar *This, LPCOLESTR data, strbuf *buf)
{ {
LPCOLESTR iter, iter2 = data; LPCOLESTR iter, iter2 = data;
rep_list *rep_iter; rep_list *rep_iter;
static const WCHAR wstr[] = {'%',0};
iter = wcschr(data, '%'); iter = wcschr(data, '%');
while(iter) { while(iter) {
@ -164,7 +156,7 @@ static HRESULT do_preprocess(const Registrar *This, LPCOLESTR data, strbuf *buf)
return DISP_E_EXCEPTION; return DISP_E_EXCEPTION;
if(iter == iter2) { if(iter == iter2) {
strbuf_write(wstr, buf, 1); strbuf_write(L"%", buf, 1);
}else { }else {
for(rep_iter = This->rep; rep_iter; rep_iter = rep_iter->next) { for(rep_iter = This->rep; rep_iter; rep_iter = rep_iter->next) {
if(rep_iter->key_len == iter-iter2 if(rep_iter->key_len == iter-iter2
@ -205,11 +197,6 @@ static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOO
DO_DELETE DO_DELETE
} key_type = NORMAL; } key_type = NORMAL;
static const WCHAR wstrNoRemove[] = {'N','o','R','e','m','o','v','e',0};
static const WCHAR wstrForceRemove[] = {'F','o','r','c','e','R','e','m','o','v','e',0};
static const WCHAR wstrDelete[] = {'D','e','l','e','t','e',0};
static const WCHAR wstrval[] = {'v','a','l',0};
iter = *pstr; iter = *pstr;
hres = get_word(&iter, buf); hres = get_word(&iter, buf);
if(FAILED(hres)) if(FAILED(hres))
@ -218,13 +205,13 @@ static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOO
while(buf->str[1] || buf->str[0] != '}') { while(buf->str[1] || buf->str[0] != '}') {
key_type = NORMAL; key_type = NORMAL;
if(!lstrcmpiW(buf->str, wstrNoRemove)) if(!lstrcmpiW(buf->str, L"NoRemove"))
key_type = NO_REMOVE; key_type = NO_REMOVE;
else if(!lstrcmpiW(buf->str, wstrForceRemove)) else if(!lstrcmpiW(buf->str, L"ForceRemove"))
key_type = FORCE_REMOVE; key_type = FORCE_REMOVE;
else if(!lstrcmpiW(buf->str, wstrval)) else if(!lstrcmpiW(buf->str, L"val"))
key_type = IS_VAL; key_type = IS_VAL;
else if(!lstrcmpiW(buf->str, wstrDelete)) else if(!lstrcmpiW(buf->str, L"Delete"))
key_type = DO_DELETE; key_type = DO_DELETE;
if(key_type != NORMAL) { if(key_type != NORMAL) {
@ -716,9 +703,6 @@ HRESULT WINAPI AtlUpdateRegistryFromResourceD(HINSTANCE inst, LPCOLESTR res,
IRegistrar *registrar; IRegistrar *registrar;
HRESULT hres; HRESULT hres;
static const WCHAR moduleW[] = {'M','O','D','U','L','E',0};
static const WCHAR registryW[] = {'R','E','G','I','S','T','R','Y',0};
if(!GetModuleFileNameW(inst, module_name, MAX_PATH)) { if(!GetModuleFileNameW(inst, module_name, MAX_PATH)) {
FIXME("hinst %p: did not get module name\n", inst); FIXME("hinst %p: did not get module name\n", inst);
return E_FAIL; return E_FAIL;
@ -735,15 +719,15 @@ HRESULT WINAPI AtlUpdateRegistryFromResourceD(HINSTANCE inst, LPCOLESTR res,
return hres; return hres;
} }
IRegistrar_AddReplacement(registrar, moduleW, module_name); IRegistrar_AddReplacement(registrar, L"MODULE", module_name);
for (iter = pMapEntries; iter && iter->szKey; iter++) for (iter = pMapEntries; iter && iter->szKey; iter++)
IRegistrar_AddReplacement(registrar, iter->szKey, iter->szData); IRegistrar_AddReplacement(registrar, iter->szKey, iter->szData);
if(bRegister) if(bRegister)
hres = IRegistrar_ResourceRegisterSz(registrar, module_name, res, registryW); hres = IRegistrar_ResourceRegisterSz(registrar, module_name, res, L"REGISTRY");
else else
hres = IRegistrar_ResourceUnregisterSz(registrar, module_name, res, registryW); hres = IRegistrar_ResourceUnregisterSz(registrar, module_name, res, L"REGISTRY");
if(registrar != pReg) if(registrar != pReg)
IRegistrar_Release(registrar); IRegistrar_Release(registrar);

View File

@ -115,7 +115,6 @@ static void test_ax_win(void)
{ {
BOOL ret; BOOL ret;
WNDCLASSEXW wcex; WNDCLASSEXW wcex;
static const WCHAR AtlAxWin[] = {'A','t','l','A','x','W','i','n',0};
static HMODULE hinstance = 0; static HMODULE hinstance = 0;
ret = AtlAxWinInit(); ret = AtlAxWinInit();
@ -124,7 +123,7 @@ static void test_ax_win(void)
hinstance = GetModuleHandleA(NULL); hinstance = GetModuleHandleA(NULL);
memset(&wcex, 0, sizeof(wcex)); memset(&wcex, 0, sizeof(wcex));
wcex.cbSize = sizeof(wcex); wcex.cbSize = sizeof(wcex);
ret = GetClassInfoExW(hinstance, AtlAxWin, &wcex); ret = GetClassInfoExW(hinstance, L"AtlAxWin", &wcex);
ok(ret, "AtlAxWin has not registered\n"); ok(ret, "AtlAxWin has not registered\n");
ok(wcex.style == CS_GLOBALCLASS, "wcex.style %08x\n", wcex.style); ok(wcex.style == CS_GLOBALCLASS, "wcex.style %08x\n", wcex.style);
} }