2 * Copyright 2014 Alistair Leslie-Hughes
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.
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.
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
21 #define WIN32_LEAN_AND_MEAN
23 #include <wine/test.h>
27 static void create_configuration(void)
29 static const WCHAR tcpipW
[] = {'M','S','_','T','C','P','I','P',0};
30 static const WCHAR myclient
[] = {'M','Y',' ','C','L','I','E','N','T',0};
32 INetCfg
*config
= NULL
;
33 INetCfgLock
*netlock
= NULL
;
34 INetCfgComponent
*component
= NULL
;
37 hr
= CoCreateInstance( &CLSID_CNetCfg
, NULL
, CLSCTX_ALL
, &IID_INetCfg
, (LPVOID
*)&config
);
38 ok(hr
== S_OK
, "Failed to create object\n");
41 hr
= INetCfg_QueryInterface(config
, &IID_INetCfgLock
, (LPVOID
*)&netlock
);
42 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
44 hr
= INetCfgLock_AcquireWriteLock(netlock
, 5000, myclient
, &client
);
46 hr
== E_ACCESSDENIED
/* Not run as admin */, "got 0x%08x\n", hr
);
49 trace("Lock value: %s\n", wine_dbgstr_w(client
));
50 CoTaskMemFree(client
);
52 else if(hr
== E_ACCESSDENIED
)
53 trace("Not run with Admin permissions\n");
55 hr
= INetCfg_Initialize(config
, NULL
);
56 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
58 /* AcquireWriteLock needs to be run before Initialize */
59 hr
= INetCfgLock_AcquireWriteLock(netlock
, 5000, myclient
, &client
);
60 todo_wine
ok(hr
== NETCFG_E_ALREADY_INITIALIZED
|| hr
== E_ACCESSDENIED
, "got 0x%08x\n", hr
);
62 hr
= INetCfg_FindComponent(config
, tcpipW
, &component
);
63 todo_wine
ok(hr
== S_OK
, "got 0x%08x\n", hr
);
66 INetCfgComponent_Release(component
);
69 hr
= INetCfg_Apply(config
);
70 todo_wine
ok(hr
== S_OK
|| hr
== NETCFG_E_NO_WRITE_LOCK
, "got 0x%08x\n", hr
);
72 hr
= INetCfg_Uninitialize(config
);
73 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
75 hr
= INetCfgLock_ReleaseWriteLock(netlock
);
76 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
78 INetCfgLock_Release(netlock
);
79 INetCfg_Release(config
);
88 ok( hr
== S_OK
, "failed to init com\n");
92 create_configuration();