2010-11-24 10:09:05 +01:00
|
|
|
/*
|
|
|
|
* ATL test program
|
|
|
|
*
|
|
|
|
* Copyright 2010 Damjan Jovanovic
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include <wine/test.h>
|
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include <winuser.h>
|
|
|
|
#include <wingdi.h>
|
|
|
|
#include <winnls.h>
|
|
|
|
#include <winerror.h>
|
|
|
|
#include <winnt.h>
|
|
|
|
#include <wtypes.h>
|
|
|
|
#include <olectl.h>
|
|
|
|
#include <ocidl.h>
|
|
|
|
#include <initguid.h>
|
|
|
|
#include <atliface.h>
|
|
|
|
|
|
|
|
static const char textA[] =
|
2014-03-06 14:56:04 +01:00
|
|
|
"HKCU \n"
|
2010-11-24 10:09:05 +01:00
|
|
|
"{ \n"
|
|
|
|
" ForceRemove eebf73c4-50fd-478f-bbcf-db212221227a \n"
|
|
|
|
" { \n"
|
|
|
|
" val 'string' = s 'string' \n"
|
|
|
|
" val 'dword_quoted_dec' = d '1' \n"
|
|
|
|
" val 'dword_unquoted_dec' = d 1 \n"
|
|
|
|
" val 'dword_quoted_hex' = d '0xA' \n"
|
|
|
|
" val 'dword_unquoted_hex' = d 0xA \n"
|
2010-11-24 10:10:13 +01:00
|
|
|
" val 'binary_quoted' = b 'deadbeef' \n"
|
2020-02-06 14:13:21 +01:00
|
|
|
" val 'binary_unquoted' = b dead0123 \n"
|
2010-11-24 10:09:05 +01:00
|
|
|
" } \n"
|
|
|
|
"}";
|
|
|
|
|
|
|
|
static void test_registrar(void)
|
|
|
|
{
|
|
|
|
IRegistrar *registrar = NULL;
|
|
|
|
HRESULT hr;
|
|
|
|
INT count;
|
|
|
|
WCHAR *textW = NULL;
|
|
|
|
|
2010-11-28 15:40:31 +01:00
|
|
|
if (!GetProcAddress(GetModuleHandleA("atl.dll"), "AtlAxAttachControl"))
|
|
|
|
{
|
|
|
|
win_skip("Old versions of atl.dll don't support binary values\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-24 10:09:05 +01:00
|
|
|
hr = CoCreateInstance(&CLSID_Registrar, NULL, CLSCTX_INPROC_SERVER, &IID_IRegistrar, (void**)®istrar);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2014-03-06 14:56:04 +01:00
|
|
|
win_skip("creating IRegistrar failed, hr = 0x%08X\n", hr);
|
2010-11-24 10:09:05 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
count = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0);
|
|
|
|
textW = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR));
|
|
|
|
if (textW)
|
|
|
|
{
|
|
|
|
DWORD dword;
|
|
|
|
DWORD size;
|
|
|
|
LONG lret;
|
|
|
|
HKEY key;
|
2010-11-24 10:10:13 +01:00
|
|
|
BYTE bytes[4];
|
2010-11-24 10:09:05 +01:00
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, count);
|
|
|
|
hr = IRegistrar_StringRegister(registrar, textW);
|
2014-03-06 14:56:04 +01:00
|
|
|
ok(hr == S_OK, "StringRegister failed: %08x\n", hr);
|
2014-02-12 17:07:09 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IRegistrar_Release(registrar);
|
|
|
|
return;
|
|
|
|
}
|
2010-11-24 10:09:05 +01:00
|
|
|
|
2014-03-06 14:56:04 +01:00
|
|
|
lret = RegOpenKeyA(HKEY_CURRENT_USER, "eebf73c4-50fd-478f-bbcf-db212221227a", &key);
|
2010-11-24 10:09:05 +01:00
|
|
|
ok(lret == ERROR_SUCCESS, "error %d opening registry key\n", lret);
|
|
|
|
|
|
|
|
size = sizeof(dword);
|
|
|
|
lret = RegQueryValueExA(key, "dword_unquoted_hex", NULL, NULL, (BYTE*)&dword, &size);
|
|
|
|
ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %d\n", lret);
|
|
|
|
ok(dword != 0xA, "unquoted hex is not supposed to be preserved\n");
|
|
|
|
|
|
|
|
size = sizeof(dword);
|
|
|
|
lret = RegQueryValueExA(key, "dword_quoted_hex", NULL, NULL, (BYTE*)&dword, &size);
|
|
|
|
ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %d\n", lret);
|
|
|
|
ok(dword != 0xA, "quoted hex is not supposed to be preserved\n");
|
|
|
|
|
|
|
|
size = sizeof(dword);
|
|
|
|
lret = RegQueryValueExA(key, "dword_unquoted_dec", NULL, NULL, (BYTE*)&dword, &size);
|
|
|
|
ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %d\n", lret);
|
|
|
|
ok(dword == 1, "unquoted dec is not supposed to be %d\n", dword);
|
|
|
|
|
|
|
|
size = sizeof(dword);
|
|
|
|
lret = RegQueryValueExA(key, "dword_quoted_dec", NULL, NULL, (BYTE*)&dword, &size);
|
|
|
|
ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %d\n", lret);
|
|
|
|
ok(dword == 1, "quoted dec is not supposed to be %d\n", dword);
|
|
|
|
|
2010-11-24 10:10:13 +01:00
|
|
|
size = 4;
|
|
|
|
lret = RegQueryValueExA(key, "binary_quoted", NULL, NULL, bytes, &size);
|
|
|
|
ok(lret == ERROR_SUCCESS, "RegQueryValueA, failed, error %d\n", lret);
|
2010-11-28 15:40:31 +01:00
|
|
|
ok(bytes[0] == 0xde && bytes[1] == 0xad && bytes[2] == 0xbe && bytes[3] == 0xef,
|
2010-11-24 10:10:13 +01:00
|
|
|
"binary quoted value was not preserved (it's 0x%02X%02X%02X%02X)\n",
|
|
|
|
0xff & bytes[0], 0xff & bytes[1], 0xff & bytes[2], 0xff & bytes[3]);
|
|
|
|
|
|
|
|
size = 4;
|
|
|
|
lret = RegQueryValueExA(key, "binary_unquoted", NULL, NULL, bytes, &size);
|
|
|
|
ok(lret == ERROR_SUCCESS, "RegQueryValueA, failed, error %d\n", lret);
|
2020-02-06 14:13:21 +01:00
|
|
|
ok(bytes[0] == 0xde && bytes[1] == 0xad && bytes[2] == 0x01 && bytes[3] == 0x23,
|
2010-11-24 10:10:13 +01:00
|
|
|
"binary unquoted value was not preserved (it's 0x%02X%02X%02X%02X)\n",
|
|
|
|
0xff & bytes[0], 0xff & bytes[1], 0xff & bytes[2], 0xff & bytes[3]);
|
|
|
|
|
2010-11-24 10:09:05 +01:00
|
|
|
hr = IRegistrar_StringUnregister(registrar, textW);
|
2010-11-28 15:40:31 +01:00
|
|
|
ok(SUCCEEDED(hr), "IRegistrar_StringUnregister failed, hr = 0x%08X\n", hr);
|
2010-11-24 10:09:05 +01:00
|
|
|
RegCloseKey(key);
|
2010-11-28 15:40:31 +01:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, textW);
|
2010-11-24 10:09:05 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("allocating memory failed\n");
|
|
|
|
|
|
|
|
IRegistrar_Release(registrar);
|
|
|
|
}
|
|
|
|
|
2012-11-15 11:21:57 +01:00
|
|
|
static void test_aggregation(void)
|
|
|
|
{
|
|
|
|
IUnknown *unk = (IUnknown*)0xdeadbeef;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = CoCreateInstance(&CLSID_Registrar, (IUnknown*)0xdeadbeef, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
|
|
|
&IID_IUnknown, (void**)&unk);
|
2013-07-01 00:18:18 +02:00
|
|
|
ok(hres == CLASS_E_NOAGGREGATION || broken(hres == E_INVALIDARG),
|
|
|
|
"CoCreateInstance failed: %08x, expected CLASS_E_NOAGGREGATION\n", hres);
|
|
|
|
ok(!unk || unk == (IUnknown*)0xdeadbeef, "unk = %p\n", unk);
|
2012-11-15 11:21:57 +01:00
|
|
|
}
|
|
|
|
|
2010-11-24 10:09:05 +01:00
|
|
|
START_TEST(registrar)
|
|
|
|
{
|
|
|
|
CoInitialize(NULL);
|
|
|
|
|
|
|
|
test_registrar();
|
2012-11-15 11:21:57 +01:00
|
|
|
test_aggregation();
|
2010-11-24 10:09:05 +01:00
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
}
|