ReactOS 0.4.16-dev-340-g0540c21
netcfgx.c
Go to the documentation of this file.
1/*
2 * Copyright 2014 Alistair Leslie-Hughes
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18#define WIN32_LEAN_AND_MEAN
19#include <stdio.h>
20
21#define COBJMACROS
22
23#ifdef __REACTOS__
24#include <objbase.h>
25#endif
26#include "netcfgx.h"
27#include "wine/test.h"
28
29static void create_configuration(void)
30{
31 static const WCHAR tcpipW[] = {'M','S','_','T','C','P','I','P',0};
32 static const WCHAR myclient[] = {'M','Y',' ','C','L','I','E','N','T',0};
33 HRESULT hr;
34 INetCfg *config = NULL;
35 INetCfgLock *netlock = NULL;
36 INetCfgComponent *component = NULL;
38
40 ok(hr == S_OK, "Failed to create object\n");
41 if(SUCCEEDED(hr))
42 {
44 ok(hr == S_OK, "got 0x%08x\n", hr);
45
46 hr = INetCfgLock_AcquireWriteLock(netlock, 5000, myclient, &client);
47 ok(hr == S_OK ||
48 hr == E_ACCESSDENIED /* Not run as admin */, "got 0x%08x\n", hr);
49 if(hr == S_OK)
50 {
51 trace("Lock value: %s\n", wine_dbgstr_w(client));
53 }
54 else if(hr == E_ACCESSDENIED)
55 trace("Not run with Admin permissions\n");
56
58 ok(hr == S_OK, "got 0x%08x\n", hr);
59
60 /* AcquireWriteLock needs to be run before Initialize */
61 hr = INetCfgLock_AcquireWriteLock(netlock, 5000, myclient, &client);
63
64 hr = INetCfg_FindComponent(config, tcpipW, &component);
65 todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
66 if(hr == S_OK)
67 {
68 INetCfgComponent_Release(component);
69 }
70
72 todo_wine ok(hr == S_OK || hr == NETCFG_E_NO_WRITE_LOCK, "got 0x%08x\n", hr);
73
75 ok(hr == S_OK, "got 0x%08x\n", hr);
76
78 ok(hr == S_OK, "got 0x%08x\n", hr);
79
80 INetCfgLock_Release(netlock);
82 }
83}
84
85START_TEST(netcfgx)
86{
87 HRESULT hr;
88
89 hr = CoInitialize(0);
90 ok( hr == S_OK, "failed to init com\n");
91 if (hr != S_OK)
92 return;
93
95
97}
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define wine_dbgstr_w
Definition: kernel32.h:34
#define todo_wine
Definition: custom.c:89
static void create_configuration(void)
Definition: netcfgx.c:29
#define NETCFG_E_NO_WRITE_LOCK
Definition: netcfgx.h:305
#define INetCfg_Release(p)
Definition: netcfgx.h:289
#define INetCfgComponent_Release(p)
Definition: netcfgx.h:62
#define INetCfg_Apply(p)
Definition: netcfgx.h:292
#define INetCfg_QueryInterface(p, a, b)
Definition: netcfgx.h:287
EXTERN_C const IID IID_INetCfgLock
Definition: netcfgx.h:17
EXTERN_C const GUID CLSID_CNetCfg
Definition: netcfgx.h:299
#define INetCfgLock_AcquireWriteLock(p, a, b, c)
Definition: netcfgx.h:24
#define INetCfgLock_ReleaseWriteLock(p)
Definition: netcfgx.h:25
#define INetCfg_Uninitialize(p)
Definition: netcfgx.h:291
#define INetCfgLock_Release(p)
Definition: netcfgx.h:23
#define INetCfg_FindComponent(p, a, b)
Definition: netcfgx.h:295
EXTERN_C const IID IID_INetCfg
Definition: netcfgx.h:300
#define NETCFG_E_ALREADY_INITIALIZED
Definition: netcfgx.h:302
#define INetCfg_Initialize(p, a)
Definition: netcfgx.h:290
static FILE * client
Definition: client.c:41
HRESULT hr
Definition: shlfolder.c:183
#define E_ACCESSDENIED
Definition: winerror.h:2849
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184