2 * Copyright 2012 Hans Leidekker for CodeWeavers
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
28 #include "wine/test.h"
30 static const WCHAR wqlW
[] = {'w','q','l',0};
32 static HRESULT
exec_query( IWbemServices
*services
, const WCHAR
*str
, IEnumWbemClassObject
**result
)
34 static const WCHAR captionW
[] = {'C','a','p','t','i','o','n',0};
35 static const WCHAR descriptionW
[] = {'D','e','s','c','r','i','p','t','i','o','n',0};
37 IWbemClassObject
*obj
;
38 BSTR wql
= SysAllocString( wqlW
), query
= SysAllocString( str
);
39 LONG flags
= WBEM_FLAG_RETURN_IMMEDIATELY
| WBEM_FLAG_FORWARD_ONLY
;
42 hr
= IWbemServices_ExecQuery( services
, wql
, query
, flags
, NULL
, result
);
45 trace("%s\n", wine_dbgstr_w(str
));
50 IEnumWbemClassObject_Next( *result
, 10000, 1, &obj
, &count
);
53 if (IWbemClassObject_Get( obj
, captionW
, 0, &var
, NULL
, NULL
) == WBEM_S_NO_ERROR
)
55 trace("caption: %s\n", wine_dbgstr_w(V_BSTR(&var
)));
58 if (IWbemClassObject_Get( obj
, descriptionW
, 0, &var
, NULL
, NULL
) == WBEM_S_NO_ERROR
)
60 trace("description: %s\n", wine_dbgstr_w(V_BSTR(&var
)));
63 IWbemClassObject_Release( obj
);
67 SysFreeString( query
);
71 static void test_select( IWbemServices
*services
)
73 static const WCHAR emptyW
[] = {0};
74 static const WCHAR sqlW
[] = {'S','Q','L',0};
75 static const WCHAR query1
[] =
76 {'S','E','L','E','C','T',' ','H','O','T','F','I','X','I','D',' ','F','R','O','M',' ',
77 'W','i','n','3','2','_','Q','u','i','c','k','F','i','x','E','n','g','i','n','e','e','r','i','n','g',0};
78 static const WCHAR query2
[] =
79 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_','B','I','O','S',0};
80 static const WCHAR query3
[] =
81 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
82 'L','o','g','i','c','a','l','D','i','s','k',' ','W','H','E','R','E',' ',
83 '\"','N','T','F','S','\"',' ','=',' ','F','i','l','e','S','y','s','t','e','m',0};
84 static const WCHAR query4
[] =
85 {'S','E','L','E','C','T',' ','a',' ','F','R','O','M',' ','b',0};
86 static const WCHAR query5
[] =
87 {'S','E','L','E','C','T',' ','a',' ','F','R','O','M',' ','W','i','n','3','2','_','B','i','o','s',0};
88 static const WCHAR query6
[] =
89 {'S','E','L','E','C','T',' ','D','e','s','c','r','i','p','t','i','o','n',' ','F','R','O','M',' ',
90 'W','i','n','3','2','_','B','i','o','s',0};
91 static const WCHAR query7
[] =
92 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
93 'P','r','o','c','e','s','s',' ','W','H','E','R','E',' ','C','a','p','t','i','o','n',' ',
94 'L','I','K','E',' ','\'','%','%','R','E','G','E','D','I','T','%','\'',0};
95 static const WCHAR query8
[] =
96 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
97 'D','i','s','k','D','r','i','v','e',' ','W','H','E','R','E',' ','D','e','v','i','c','e','I','D','=',
98 '\"','\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0','\"',0};
99 static const WCHAR query9
[] =
100 {'S','E','L','E','C','T','\n','a','\r','F','R','O','M','\t','b',0};
101 static const WCHAR query10
[] =
102 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
103 'P','r','o','c','e','s','s',' ','W','H','E','R','E',' ','C','a','p','t','i','o','n',' ',
104 'L','I','K','E',' ','"','%','f','i','r','e','f','o','x','.','e','x','e','"',0};
105 static const WCHAR query11
[] =
106 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
107 'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',' ','w','h','e','r','e',' ',
108 'a','v','a','i','l','a','b','i','l','i','t','y',' ','=',' ','\'','3','\'',0};
109 static const WCHAR query12
[] =
110 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_','B','I','O','S',
111 ' ','W','H','E','R','E',' ','N','A','M','E',' ','<','>',' ','N','U','L','L', 0};
112 static const WCHAR query13
[] =
113 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_','B','I','O','S',
114 ' ','W','H','E','R','E',' ','N','U','L','L',' ','=',' ','N','A','M','E', 0};
115 static const WCHAR
*test
[] = { query1
, query2
, query3
, query4
, query5
, query6
, query7
, query8
, query9
, query10
,
116 query11
, query12
, query13
};
118 IEnumWbemClassObject
*result
;
119 BSTR wql
= SysAllocString( wqlW
);
120 BSTR sql
= SysAllocString( sqlW
);
121 BSTR query
= SysAllocString( query1
);
124 hr
= IWbemServices_ExecQuery( services
, NULL
, NULL
, 0, NULL
, &result
);
125 ok( hr
== WBEM_E_INVALID_PARAMETER
, "query failed %08x\n", hr
);
127 hr
= IWbemServices_ExecQuery( services
, NULL
, query
, 0, NULL
, &result
);
128 ok( hr
== WBEM_E_INVALID_PARAMETER
, "query failed %08x\n", hr
);
130 hr
= IWbemServices_ExecQuery( services
, wql
, NULL
, 0, NULL
, &result
);
131 ok( hr
== WBEM_E_INVALID_PARAMETER
, "query failed %08x\n", hr
);
133 hr
= IWbemServices_ExecQuery( services
, sql
, query
, 0, NULL
, &result
);
134 ok( hr
== WBEM_E_INVALID_QUERY_TYPE
, "query failed %08x\n", hr
);
136 hr
= IWbemServices_ExecQuery( services
, sql
, NULL
, 0, NULL
, &result
);
137 ok( hr
== WBEM_E_INVALID_PARAMETER
, "query failed %08x\n", hr
);
139 SysFreeString( query
);
140 query
= SysAllocString( emptyW
);
141 hr
= IWbemServices_ExecQuery( services
, wql
, query
, 0, NULL
, &result
);
142 ok( hr
== WBEM_E_INVALID_PARAMETER
, "query failed %08x\n", hr
);
144 for (i
= 0; i
< ARRAY_SIZE( test
); i
++)
146 hr
= exec_query( services
, test
[i
], &result
);
147 ok( hr
== S_OK
, "query %u failed: %08x\n", i
, hr
);
148 if (result
) IEnumWbemClassObject_Release( result
);
151 SysFreeString( wql
);
152 SysFreeString( sql
);
153 SysFreeString( query
);
156 static void test_associators( IWbemServices
*services
)
158 static const WCHAR query1
[] =
159 {'A','S','S','O','C','I','A','T','O','R','S',' ','O','F',' ','{','W','i','n','3','2','_',
160 'L','o','g','i','c','a','l','D','i','s','k','.','D','e','v','i','c','e','I','D','=','"','C',':','"','}',0};
161 static const WCHAR query2
[] =
162 {'A','S','S','O','C','I','A','T','O','R','S',' ','O','F',' ','{','W','i','n','3','2','_',
163 'L','o','g','i','c','a','l','D','i','s','k','.','D','e','v','i','c','e','I','D','=','"','C',':','"','}',' ',
164 'W','H','E','R','E',' ','A','s','s','o','c','C','l','a','s','s',' ','=',' ','W','i','n','3','2','_',
165 'L','o','g','i','c','a','l','D','i','s','k','T','o','P','a','r','t','i','t','i','o','n',0};
166 static const WCHAR
*test
[] = { query1
, query2
};
168 IEnumWbemClassObject
*result
;
171 for (i
= 0; i
< ARRAY_SIZE( test
); i
++)
173 hr
= exec_query( services
, test
[i
], &result
);
174 todo_wine
ok( hr
== S_OK
, "query %u failed: %08x\n", i
, hr
);
175 if (result
) IEnumWbemClassObject_Release( result
);
179 static void test_Win32_Service( IWbemServices
*services
)
181 static const WCHAR returnvalueW
[] = {'R','e','t','u','r','n','V','a','l','u','e',0};
182 static const WCHAR pauseserviceW
[] = {'P','a','u','s','e','S','e','r','v','i','c','e',0};
183 static const WCHAR resumeserviceW
[] = {'R','e','s','u','m','e','S','e','r','v','i','c','e',0};
184 static const WCHAR startserviceW
[] = {'S','t','a','r','t','S','e','r','v','i','c','e',0};
185 static const WCHAR stopserviceW
[] = {'S','t','o','p','S','e','r','v','i','c','e',0};
186 static const WCHAR stateW
[] = {'S','t','a','t','e',0};
187 static const WCHAR stoppedW
[] = {'S','t','o','p','p','e','d',0};
188 static const WCHAR serviceW
[] = {'W','i','n','3','2','_','S','e','r','v','i','c','e','.',
189 'N','a','m','e','=','"','S','p','o','o','l','e','r','"',0};
190 static const WCHAR emptyW
[] = {0};
191 BSTR
class = SysAllocString( serviceW
), empty
= SysAllocString( emptyW
), method
;
192 IWbemClassObject
*service
, *out
;
193 VARIANT state
, retval
;
197 hr
= IWbemServices_GetObject( services
, class, 0, NULL
, &service
, NULL
);
200 win_skip( "Win32_Service not available\n" );
204 VariantInit( &state
);
205 hr
= IWbemClassObject_Get( service
, stateW
, 0, &state
, &type
, NULL
);
206 ok( hr
== S_OK
, "failed to get service state %08x\n", hr
);
207 ok( V_VT( &state
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &state
) );
208 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
210 if (!lstrcmpW( V_BSTR( &state
), stoppedW
))
213 method
= SysAllocString( startserviceW
);
214 hr
= IWbemServices_ExecMethod( services
, class, method
, 0, NULL
, NULL
, &out
, NULL
);
215 ok( hr
== S_OK
, "failed to execute method %08x\n", hr
);
216 SysFreeString( method
);
218 VariantInit( &retval
);
219 hr
= IWbemClassObject_Get( out
, returnvalueW
, 0, &retval
, NULL
, NULL
);
220 ok( hr
== S_OK
, "failed to get return value %08x\n", hr
);
221 ok( !V_I4( &retval
), "unexpected error %u\n", V_UI4( &retval
) );
222 IWbemClassObject_Release( out
);
225 method
= SysAllocString( pauseserviceW
);
226 hr
= IWbemServices_ExecMethod( services
, class, method
, 0, NULL
, NULL
, &out
, NULL
);
227 ok( hr
== S_OK
, "failed to execute method %08x\n", hr
);
228 SysFreeString( method
);
230 VariantInit( &retval
);
231 hr
= IWbemClassObject_Get( out
, returnvalueW
, 0, &retval
, NULL
, NULL
);
232 ok( hr
== S_OK
, "failed to get return value %08x\n", hr
);
233 ok( V_I4( &retval
), "unexpected success\n" );
234 IWbemClassObject_Release( out
);
237 method
= SysAllocString( resumeserviceW
);
238 hr
= IWbemServices_ExecMethod( services
, class, method
, 0, NULL
, NULL
, &out
, NULL
);
239 ok( hr
== S_OK
, "failed to execute method %08x\n", hr
);
240 SysFreeString( method
);
242 VariantInit( &retval
);
243 hr
= IWbemClassObject_Get( out
, returnvalueW
, 0, &retval
, NULL
, NULL
);
244 ok( hr
== S_OK
, "failed to get return value %08x\n", hr
);
245 ok( V_I4( &retval
), "unexpected success\n" );
246 IWbemClassObject_Release( out
);
248 if (!lstrcmpW( V_BSTR( &state
), stoppedW
))
251 method
= SysAllocString( stopserviceW
);
252 hr
= IWbemServices_ExecMethod( services
, class, method
, 0, NULL
, NULL
, &out
, NULL
);
253 ok( hr
== S_OK
, "failed to execute method %08x\n", hr
);
254 SysFreeString( method
);
256 VariantInit( &retval
);
257 hr
= IWbemClassObject_Get( out
, returnvalueW
, 0, &retval
, NULL
, NULL
);
258 ok( hr
== S_OK
, "failed to get return value %08x\n", hr
);
259 ok( !V_I4( &retval
), "unexpected error %u\n", V_UI4( &retval
) );
260 IWbemClassObject_Release( out
);
262 VariantClear( &state
);
263 IWbemClassObject_Release( service
);
266 hr
= IWbemServices_GetObject( services
, NULL
, 0, NULL
, &service
, NULL
);
267 ok( hr
== S_OK
, "got %08x\n", hr
);
268 if (service
) IWbemClassObject_Release( service
);
271 hr
= IWbemServices_GetObject( services
, empty
, 0, NULL
, &service
, NULL
);
272 ok( hr
== S_OK
, "got %08x\n", hr
);
273 if (service
) IWbemClassObject_Release( service
);
276 SysFreeString( empty
);
277 SysFreeString( class );
280 static void test_Win32_Bios( IWbemServices
*services
)
282 static const WCHAR queryW
[] =
283 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_', 'B','i','o','s',0};
284 static const WCHAR descriptionW
[] = {'D','e','s','c','r','i','p','t','i','o','n',0};
285 static const WCHAR identificationcodeW
[] = {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
286 static const WCHAR manufacturerW
[] = {'M','a','n','u','f','a','c','t','u','r','e','r',0};
287 static const WCHAR nameW
[] = {'N','a','m','e',0};
288 static const WCHAR releasedateW
[] = {'R','e','l','e','a','s','e','D','a','t','e',0};
289 static const WCHAR serialnumberW
[] = {'S','e','r','i','a','l','N','u','m','b','e','r',0};
290 static const WCHAR smbiosbiosversionW
[] = {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
291 static const WCHAR smbiosmajorversionW
[] = {'S','M','B','I','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
292 static const WCHAR smbiosminorversionW
[] = {'S','M','B','I','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
293 static const WCHAR versionW
[] = {'V','e','r','s','i','o','n',0};
294 BSTR wql
= SysAllocString( wqlW
), query
= SysAllocString( queryW
);
295 IEnumWbemClassObject
*result
;
296 IWbemClassObject
*obj
;
302 hr
= IWbemServices_ExecQuery( services
, wql
, query
, 0, NULL
, &result
);
303 ok( hr
== S_OK
, "IWbemServices_ExecQuery failed %08x\n", hr
);
305 hr
= IEnumWbemClassObject_Next( result
, 10000, 1, &obj
, &count
);
306 ok( hr
== S_OK
, "IEnumWbemClassObject_Next failed %08x\n", hr
);
310 hr
= IWbemClassObject_Get( obj
, descriptionW
, 0, &val
, &type
, NULL
);
311 ok( hr
== S_OK
, "failed to get description %08x\n", hr
);
312 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
313 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
314 trace( "description: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
315 VariantClear( &val
);
319 hr
= IWbemClassObject_Get( obj
, identificationcodeW
, 0, &val
, &type
, NULL
);
320 ok( hr
== S_OK
, "failed to get identication code %08x\n", hr
);
321 ok( V_VT( &val
) == VT_NULL
, "unexpected variant type 0x%x\n", V_VT( &val
) );
322 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
323 VariantClear( &val
);
327 hr
= IWbemClassObject_Get( obj
, manufacturerW
, 0, &val
, &type
, NULL
);
328 ok( hr
== S_OK
, "failed to get manufacturer %08x\n", hr
);
329 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
330 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
331 trace( "manufacturer: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
332 VariantClear( &val
);
336 hr
= IWbemClassObject_Get( obj
, nameW
, 0, &val
, &type
, NULL
);
337 ok( hr
== S_OK
, "failed to get name %08x\n", hr
);
338 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
339 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
340 trace( "name: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
341 VariantClear( &val
);
345 hr
= IWbemClassObject_Get( obj
, releasedateW
, 0, &val
, &type
, NULL
);
346 ok( hr
== S_OK
, "failed to get release date %08x\n", hr
);
347 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
348 ok( type
== CIM_DATETIME
, "unexpected type 0x%x\n", type
);
349 trace( "release date: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
350 VariantClear( &val
);
354 hr
= IWbemClassObject_Get( obj
, serialnumberW
, 0, &val
, &type
, NULL
);
355 ok( hr
== S_OK
, "failed to get serial number %08x\n", hr
);
356 ok( V_VT( &val
) == VT_BSTR
|| V_VT( &val
) == VT_NULL
/* Testbot VMs */,
357 "unexpected variant type 0x%x\n", V_VT( &val
) );
358 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
359 VariantClear( &val
);
363 hr
= IWbemClassObject_Get( obj
, smbiosbiosversionW
, 0, &val
, &type
, NULL
);
364 ok( hr
== S_OK
, "failed to get bios version %08x\n", hr
);
365 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
366 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
367 trace( "bios version: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
368 VariantClear( &val
);
372 hr
= IWbemClassObject_Get( obj
, smbiosmajorversionW
, 0, &val
, &type
, NULL
);
373 ok( hr
== S_OK
, "failed to get bios major version %08x\n", hr
);
374 ok( V_VT( &val
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &val
) );
375 ok( type
== CIM_UINT16
, "unexpected type 0x%x\n", type
);
376 trace( "bios major version: %u\n", V_I4( &val
) );
380 hr
= IWbemClassObject_Get( obj
, smbiosminorversionW
, 0, &val
, &type
, NULL
);
381 ok( hr
== S_OK
, "failed to get bios minor version %08x\n", hr
);
382 ok( V_VT( &val
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &val
) );
383 ok( type
== CIM_UINT16
, "unexpected type 0x%x\n", type
);
384 trace( "bios minor version: %u\n", V_I4( &val
) );
388 hr
= IWbemClassObject_Get( obj
, versionW
, 0, &val
, &type
, NULL
);
389 ok( hr
== S_OK
, "failed to get version %08x\n", hr
);
390 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
391 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
392 trace( "version: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
393 VariantClear( &val
);
395 IWbemClassObject_Release( obj
);
396 IEnumWbemClassObject_Release( result
);
397 SysFreeString( query
);
398 SysFreeString( wql
);
401 static void test_Win32_Process( IWbemServices
*services
, BOOL use_full_path
)
403 static const WCHAR returnvalueW
[] = {'R','e','t','u','r','n','V','a','l','u','e',0};
404 static const WCHAR getownerW
[] = {'G','e','t','O','w','n','e','r',0};
405 static const WCHAR userW
[] = {'U','s','e','r',0};
406 static const WCHAR domainW
[] = {'D','o','m','a','i','n',0};
407 static const WCHAR processW
[] = {'W','i','n','3','2','_','P','r','o','c','e','s','s',0};
408 static const WCHAR idW
[] = {'I','D',0};
409 static const WCHAR fmtW
[] = {'W','i','n','3','2','_','P','r','o','c','e','s','s','.',
410 'H','a','n','d','l','e','=','"','%','u','"',0};
411 static const WCHAR full_path_fmt
[] =
412 {'\\','\\','%','s','\\','R','O','O','T','\\','C','I','M','V','2',':',0};
413 static const LONG expected_flavor
= WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE
|
414 WBEM_FLAVOR_NOT_OVERRIDABLE
|
415 WBEM_FLAVOR_ORIGIN_PROPAGATED
;
416 WCHAR full_path
[MAX_COMPUTERNAME_LENGTH
+ ARRAY_SIZE(full_path_fmt
)];
418 IWbemClassObject
*process
, *sig_in
, *out
;
419 IWbemQualifierSet
*qualifiers
;
420 VARIANT user
, domain
, retval
, val
;
421 DWORD full_path_len
= 0;
428 WCHAR server
[MAX_COMPUTERNAME_LENGTH
+1];
430 full_path_len
= ARRAY_SIZE(server
);
431 ok( GetComputerNameW(server
, &full_path_len
), "GetComputerName failed\n" );
432 full_path_len
= wsprintfW(full_path
, full_path_fmt
, server
);
435 class = SysAllocStringLen( NULL
, full_path_len
+ ARRAY_SIZE( processW
) );
436 memcpy( class, full_path
, full_path_len
* sizeof(WCHAR
) );
437 memcpy( class + full_path_len
, processW
, sizeof(processW
) );
438 hr
= IWbemServices_GetObject( services
, class, 0, NULL
, &process
, NULL
);
439 SysFreeString( class );
442 win_skip( "Win32_Process not available\n" );
445 sig_in
= (void*)0xdeadbeef;
446 hr
= IWbemClassObject_GetMethod( process
, getownerW
, 0, &sig_in
, NULL
);
447 ok( hr
== S_OK
, "failed to get GetOwner method %08x\n", hr
);
448 ok( !sig_in
, "sig_in != NULL\n");
449 IWbemClassObject_Release( process
);
452 method
= SysAllocString( getownerW
);
453 class = SysAllocStringLen( NULL
, full_path_len
+ ARRAY_SIZE( fmtW
) + 10 );
454 memcpy( class, full_path
, full_path_len
* sizeof(WCHAR
) );
455 wsprintfW( class + full_path_len
, fmtW
, GetCurrentProcessId() );
456 hr
= IWbemServices_ExecMethod( services
, class, method
, 0, NULL
, NULL
, &out
, NULL
);
457 ok( hr
== S_OK
, "failed to execute method %08x\n", hr
);
458 SysFreeString( method
);
459 SysFreeString( class );
462 VariantInit( &retval
);
463 hr
= IWbemClassObject_Get( out
, returnvalueW
, 0, &retval
, &type
, NULL
);
464 ok( hr
== S_OK
, "failed to get return value %08x\n", hr
);
465 ok( V_VT( &retval
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &retval
) );
466 ok( !V_I4( &retval
), "unexpected error %u\n", V_I4( &retval
) );
467 ok( type
== CIM_UINT32
, "unexpected type 0x%x\n", type
);
470 VariantInit( &user
);
471 hr
= IWbemClassObject_Get( out
, userW
, 0, &user
, &type
, NULL
);
472 ok( hr
== S_OK
, "failed to get user %08x\n", hr
);
473 ok( V_VT( &user
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &user
) );
474 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
475 trace("%s\n", wine_dbgstr_w(V_BSTR(&user
)));
478 VariantInit( &domain
);
479 hr
= IWbemClassObject_Get( out
, domainW
, 0, &domain
, &type
, NULL
);
480 ok( hr
== S_OK
, "failed to get domain %08x\n", hr
);
481 ok( V_VT( &domain
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &domain
) );
482 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
483 trace("%s\n", wine_dbgstr_w(V_BSTR(&domain
)));
485 hr
= IWbemClassObject_GetPropertyQualifierSet( out
, userW
, &qualifiers
);
486 ok( hr
== S_OK
, "failed to get qualifier set %08x\n", hr
);
490 V_VT(&val
) = VT_ERROR
;
491 hr
= IWbemQualifierSet_Get( qualifiers
, idW
, 0, &val
, &flavor
);
492 ok( hr
== S_OK
, "got %08x\n", hr
);
493 ok( flavor
== expected_flavor
, "got %d\n", flavor
);
494 ok( V_VT(&val
) == VT_I4
, "got %u\n", V_VT(&val
) );
495 ok( V_I4(&val
) == 0, "got %u\n", V_I4(&val
) );
496 VariantClear( &val
);
498 IWbemQualifierSet_Release( qualifiers
);
499 hr
= IWbemClassObject_GetPropertyQualifierSet( out
, domainW
, &qualifiers
);
500 ok( hr
== S_OK
, "failed to get qualifier set %08x\n", hr
);
504 V_VT(&val
) = VT_ERROR
;
505 hr
= IWbemQualifierSet_Get( qualifiers
, idW
, 0, &val
, &flavor
);
506 ok( hr
== S_OK
, "got %08x\n", hr
);
507 ok( flavor
== expected_flavor
, "got %d\n", flavor
);
508 ok( V_VT(&val
) == VT_I4
, "got %u\n", V_VT(&val
) );
509 ok( V_I4(&val
) == 1, "got %u\n", V_I4(&val
) );
510 VariantClear( &val
);
512 IWbemQualifierSet_Release( qualifiers
);
513 hr
= IWbemClassObject_GetPropertyQualifierSet( out
, returnvalueW
, &qualifiers
);
514 ok( hr
== S_OK
, "failed to get qualifier set %08x\n", hr
);
516 hr
= IWbemQualifierSet_Get( qualifiers
, idW
, 0, &val
, &flavor
);
517 ok( hr
== WBEM_E_NOT_FOUND
, "got %08x\n", hr
);
519 IWbemQualifierSet_Release( qualifiers
);
520 VariantClear( &user
);
521 VariantClear( &domain
);
522 IWbemClassObject_Release( out
);
525 static void test_Win32_ComputerSystem( IWbemServices
*services
)
527 static const WCHAR backslashW
[] = {'\\',0};
528 static const WCHAR memorytypeW
[] = {'M','e','m','o','r','y','T','y','p','e',0};
529 static const WCHAR modelW
[] = {'M','o','d','e','l',0};
530 static const WCHAR nameW
[] = {'N','a','m','e',0};
531 static const WCHAR usernameW
[] = {'U','s','e','r','N','a','m','e',0};
532 static const WCHAR numprocessorsW
[] =
533 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
534 static const WCHAR numlogicalprocessorsW
[] =
535 {'N','u','m','b','e','r','O','f','L','o','g','i','c','a','l','P','r','o','c','e','s','s','o','r','s',0};
536 static const WCHAR queryW
[] =
537 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
538 'C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
539 BSTR wql
= SysAllocString( wqlW
), query
= SysAllocString( queryW
);
540 IEnumWbemClassObject
*result
;
541 IWbemClassObject
*obj
;
545 WCHAR compname
[MAX_COMPUTERNAME_LENGTH
+ 1];
549 len
= ARRAY_SIZE( compname
);
550 if (!GetComputerNameW( compname
, &len
))
553 lstrcpyW( username
, compname
);
554 lstrcatW( username
, backslashW
);
555 len
= ARRAY_SIZE( username
) - lstrlenW( username
);
556 if (!GetUserNameW( username
+ lstrlenW( username
), &len
))
559 if (!compname
[0] || !username
[0])
561 skip( "Failed to get user or computer name\n" );
565 hr
= IWbemServices_ExecQuery( services
, wql
, query
, 0, NULL
, &result
);
568 win_skip( "Win32_ComputerSystem not available\n" );
572 hr
= IEnumWbemClassObject_Next( result
, 10000, 1, &obj
, &count
);
573 ok( hr
== S_OK
, "got %08x\n", hr
);
576 VariantInit( &value
);
577 hr
= IWbemClassObject_Get( obj
, memorytypeW
, 0, &value
, &type
, NULL
);
578 ok( hr
== WBEM_E_NOT_FOUND
, "got %08x\n", hr
);
581 VariantInit( &value
);
582 hr
= IWbemClassObject_Get( obj
, modelW
, 0, &value
, &type
, NULL
);
583 ok( hr
== S_OK
, "failed to get model %08x\n", hr
);
584 ok( V_VT( &value
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &value
) );
585 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
586 trace( "model: %s\n", wine_dbgstr_w(V_BSTR( &value
)) );
587 VariantClear( &value
);
590 VariantInit( &value
);
591 hr
= IWbemClassObject_Get( obj
, nameW
, 0, &value
, &type
, NULL
);
592 ok( hr
== S_OK
, "failed to get computer name %08x\n", hr
);
593 ok( V_VT( &value
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &value
) );
594 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
595 ok( !lstrcmpiW( V_BSTR( &value
), compname
), "got %s, expected %s\n", wine_dbgstr_w(V_BSTR(&value
)), wine_dbgstr_w(compname
) );
596 VariantClear( &value
);
599 VariantInit( &value
);
600 hr
= IWbemClassObject_Get( obj
, numlogicalprocessorsW
, 0, &value
, &type
, NULL
);
601 ok( hr
== S_OK
|| broken(hr
== WBEM_E_NOT_FOUND
) /* win2k3 */, "got %08x\n", hr
);
604 ok( V_VT( &value
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &value
) );
605 ok( type
== CIM_UINT32
, "unexpected type 0x%x\n", type
);
606 trace( "numlogicalprocessors %u\n", V_I4( &value
) );
610 VariantInit( &value
);
611 hr
= IWbemClassObject_Get( obj
, numprocessorsW
, 0, &value
, &type
, NULL
);
612 ok( hr
== S_OK
, "got %08x\n", hr
);
613 ok( V_VT( &value
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &value
) );
614 ok( type
== CIM_UINT32
, "unexpected type 0x%x\n", type
);
615 trace( "numprocessors %u\n", V_I4( &value
) );
618 VariantInit( &value
);
619 hr
= IWbemClassObject_Get( obj
, usernameW
, 0, &value
, &type
, NULL
);
620 ok( hr
== S_OK
, "failed to get computer name %08x\n", hr
);
621 ok( V_VT( &value
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &value
) );
622 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
623 ok( !lstrcmpiW( V_BSTR( &value
), username
), "got %s, expected %s\n", wine_dbgstr_w(V_BSTR(&value
)), wine_dbgstr_w(username
) );
624 VariantClear( &value
);
626 IWbemClassObject_Release( obj
);
627 IEnumWbemClassObject_Release( result
);
629 SysFreeString( query
);
630 SysFreeString( wql
);
633 static void test_Win32_SystemEnclosure( IWbemServices
*services
)
635 static const WCHAR queryW
[] =
636 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
637 'S','y','s','t','e','m','E','n','c','l','o','s','u','r','e',0};
638 static const WCHAR captionW
[] = {'C','a','p','t','i','o','n',0};
639 static const WCHAR chassistypesW
[] = {'C','h','a','s','s','i','s','T','y','p','e','s',0};
640 static const WCHAR descriptionW
[] = {'D','e','s','c','r','i','p','t','i','o','n',0};
641 static const WCHAR lockpresentW
[] = {'L','o','c','k','P','r','e','s','e','n','t',0};
642 static const WCHAR manufacturerW
[] = {'M','a','n','u','f','a','c','t','u','r','e','r',0};
643 static const WCHAR nameW
[] = {'N','a','m','e',0};
644 static const WCHAR tagW
[] = {'T','a','g',0};
645 BSTR wql
= SysAllocString( wqlW
), query
= SysAllocString( queryW
);
646 IEnumWbemClassObject
*result
;
647 IWbemClassObject
*obj
;
654 hr
= IWbemServices_ExecQuery( services
, wql
, query
, 0, NULL
, &result
);
655 ok( hr
== S_OK
, "IWbemServices_ExecQuery failed %08x\n", hr
);
657 hr
= IEnumWbemClassObject_Next( result
, 10000, 1, &obj
, &count
);
658 ok( hr
== S_OK
, "IEnumWbemClassObject_Next failed %08x\n", hr
);
662 hr
= IWbemClassObject_Get( obj
, captionW
, 0, &val
, &type
, NULL
);
663 ok( hr
== S_OK
, "failed to get caption %08x\n", hr
);
664 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
665 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
666 trace( "caption: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
667 VariantClear( &val
);
671 hr
= IWbemClassObject_Get( obj
, chassistypesW
, 0, &val
, &type
, NULL
);
672 ok( hr
== S_OK
, "failed to get chassis types %08x\n", hr
);
673 ok( V_VT( &val
) == (VT_I4
|VT_ARRAY
), "unexpected variant type 0x%x\n", V_VT( &val
) );
674 ok( type
== (CIM_UINT16
|CIM_FLAG_ARRAY
), "unexpected type 0x%x\n", type
);
675 hr
= SafeArrayAccessData( V_ARRAY( &val
), (void **)&data
);
676 ok( hr
== S_OK
, "SafeArrayAccessData failed %x\n", hr
);
679 LONG i
, lower
, upper
;
681 hr
= SafeArrayGetLBound( V_ARRAY( &val
), 1, &lower
);
682 ok( hr
== S_OK
, "SafeArrayGetLBound failed %x\n", hr
);
683 hr
= SafeArrayGetUBound( V_ARRAY( &val
), 1, &upper
);
684 ok( hr
== S_OK
, "SafeArrayGetUBound failed %x\n", hr
);
685 if (V_VT( &val
) == (VT_I4
|VT_ARRAY
))
687 for (i
= 0; i
< upper
- lower
+ 1; i
++)
688 trace( "chassis type: %u\n", data
[i
] );
690 hr
= SafeArrayUnaccessData( V_ARRAY( &val
) );
691 ok( hr
== S_OK
, "SafeArrayUnaccessData failed %x\n", hr
);
693 VariantClear( &val
);
697 hr
= IWbemClassObject_Get( obj
, descriptionW
, 0, &val
, &type
, NULL
);
698 ok( hr
== S_OK
, "failed to get description %08x\n", hr
);
699 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
700 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
701 trace( "description: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
702 VariantClear( &val
);
706 hr
= IWbemClassObject_Get( obj
, lockpresentW
, 0, &val
, &type
, NULL
);
707 ok( hr
== S_OK
, "failed to get lockpresent %08x\n", hr
);
708 ok( V_VT( &val
) == VT_BOOL
, "unexpected variant type 0x%x\n", V_VT( &val
) );
709 ok( type
== CIM_BOOLEAN
, "unexpected type 0x%x\n", type
);
710 trace( "lockpresent: %u\n", V_BOOL( &val
) );
711 VariantClear( &val
);
715 hr
= IWbemClassObject_Get( obj
, manufacturerW
, 0, &val
, &type
, NULL
);
716 ok( hr
== S_OK
, "failed to get manufacturer %08x\n", hr
);
717 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
718 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
719 trace( "manufacturer: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
720 VariantClear( &val
);
724 hr
= IWbemClassObject_Get( obj
, nameW
, 0, &val
, &type
, NULL
);
725 ok( hr
== S_OK
, "failed to get name %08x\n", hr
);
726 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
727 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
728 trace( "name: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
729 VariantClear( &val
);
733 hr
= IWbemClassObject_Get( obj
, tagW
, 0, &val
, &type
, NULL
);
734 ok( hr
== S_OK
, "failed to get tag %08x\n", hr
);
735 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
736 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
737 trace( "tag: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
738 VariantClear( &val
);
740 IWbemClassObject_Release( obj
);
741 IEnumWbemClassObject_Release( result
);
742 SysFreeString( query
);
743 SysFreeString( wql
);
746 static void test_StdRegProv( IWbemServices
*services
)
748 static const WCHAR createkeyW
[] = {'C','r','e','a','t','e','K','e','y',0};
749 static const WCHAR enumkeyW
[] = {'E','n','u','m','K','e','y',0};
750 static const WCHAR enumvaluesW
[] = {'E','n','u','m','V','a','l','u','e','s',0};
751 static const WCHAR getstringvalueW
[] = {'G','e','t','S','t','r','i','n','g','V','a','l','u','e',0};
752 static const WCHAR stdregprovW
[] = {'S','t','d','R','e','g','P','r','o','v',0};
753 static const WCHAR defkeyW
[] = {'h','D','e','f','K','e','y',0};
754 static const WCHAR subkeynameW
[] = {'s','S','u','b','K','e','y','N','a','m','e',0};
755 static const WCHAR returnvalueW
[] = {'R','e','t','u','r','n','V','a','l','u','e',0};
756 static const WCHAR namesW
[] = {'s','N','a','m','e','s',0};
757 static const WCHAR typesW
[] = {'T','y','p','e','s',0};
758 static const WCHAR valueW
[] = {'s','V','a','l','u','e',0};
759 static const WCHAR valuenameW
[] = {'s','V','a','l','u','e','N','a','m','e',0};
760 static const WCHAR programfilesW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',0};
761 static const WCHAR windowsW
[] =
762 {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
763 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
764 static const WCHAR regtestW
[] =
765 {'S','o','f','t','w','a','r','e','\\','S','t','d','R','e','g','P','r','o','v','T','e','s','t',0};
766 BSTR
class = SysAllocString( stdregprovW
), method
, name
;
767 IWbemClassObject
*reg
, *sig_in
, *sig_out
, *in
, *out
;
768 VARIANT defkey
, subkey
, retval
, names
, types
, value
, valuename
;
773 hr
= IWbemServices_GetObject( services
, class, 0, NULL
, ®
, NULL
);
776 win_skip( "StdRegProv not available\n" );
780 hr
= IWbemClassObject_BeginMethodEnumeration( reg
, 0 );
781 ok( hr
== S_OK
, "got %08x\n", hr
);
783 while (IWbemClassObject_NextMethod( reg
, 0, &name
, &sig_in
, &sig_out
) == S_OK
)
785 SysFreeString( name
);
786 IWbemClassObject_Release( sig_in
);
787 IWbemClassObject_Release( sig_out
);
790 hr
= IWbemClassObject_EndMethodEnumeration( reg
);
791 ok( hr
== S_OK
, "got %08x\n", hr
);
793 hr
= IWbemClassObject_BeginEnumeration( reg
, 0 );
794 ok( hr
== S_OK
, "got %08x\n", hr
);
796 while (IWbemClassObject_Next( reg
, 0, &name
, NULL
, NULL
, NULL
) == S_OK
)
797 SysFreeString( name
);
799 hr
= IWbemClassObject_EndEnumeration( reg
);
800 ok( hr
== S_OK
, "got %08x\n", hr
);
802 hr
= IWbemClassObject_GetMethod( reg
, createkeyW
, 0, &sig_in
, NULL
);
803 ok( hr
== S_OK
, "failed to get CreateKey method %08x\n", hr
);
805 hr
= IWbemClassObject_SpawnInstance( sig_in
, 0, &in
);
806 ok( hr
== S_OK
, "failed to spawn instance %08x\n", hr
);
808 V_VT( &defkey
) = VT_I4
;
809 V_I4( &defkey
) = 0x80000001;
810 hr
= IWbemClassObject_Put( in
, defkeyW
, 0, &defkey
, 0 );
811 ok( hr
== S_OK
, "failed to set root %08x\n", hr
);
813 V_VT( &subkey
) = VT_BSTR
;
814 V_BSTR( &subkey
) = SysAllocString( regtestW
);
815 hr
= IWbemClassObject_Put( in
, subkeynameW
, 0, &subkey
, 0 );
816 ok( hr
== S_OK
, "failed to set subkey %08x\n", hr
);
819 method
= SysAllocString( createkeyW
);
820 hr
= IWbemServices_ExecMethod( services
, class, method
, 0, NULL
, in
, &out
, NULL
);
821 ok( hr
== S_OK
, "failed to execute method %08x\n", hr
);
822 SysFreeString( method
);
825 VariantInit( &retval
);
826 hr
= IWbemClassObject_Get( out
, returnvalueW
, 0, &retval
, &type
, NULL
);
827 ok( hr
== S_OK
, "failed to get return value %08x\n", hr
);
828 ok( V_VT( &retval
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &retval
) );
829 ok( !V_I4( &retval
), "unexpected error %u\n", V_UI4( &retval
) );
830 ok( type
== CIM_UINT32
, "unexpected type 0x%x\n", type
);
832 res
= RegDeleteKeyW( HKEY_CURRENT_USER
, regtestW
);
833 ok( !res
, "got %d\n", res
);
835 VariantClear( &subkey
);
836 IWbemClassObject_Release( in
);
837 IWbemClassObject_Release( out
);
838 IWbemClassObject_Release( sig_in
);
840 hr
= IWbemClassObject_GetMethod( reg
, enumkeyW
, 0, &sig_in
, NULL
);
841 ok( hr
== S_OK
, "failed to get EnumKey method %08x\n", hr
);
843 hr
= IWbemClassObject_SpawnInstance( sig_in
, 0, &in
);
844 ok( hr
== S_OK
, "failed to spawn instance %08x\n", hr
);
846 V_VT( &defkey
) = VT_I4
;
847 V_I4( &defkey
) = 0x80000002;
848 hr
= IWbemClassObject_Put( in
, defkeyW
, 0, &defkey
, 0 );
849 ok( hr
== S_OK
, "failed to set root %08x\n", hr
);
851 V_VT( &subkey
) = VT_BSTR
;
852 V_BSTR( &subkey
) = SysAllocString( windowsW
);
853 hr
= IWbemClassObject_Put( in
, subkeynameW
, 0, &subkey
, 0 );
854 ok( hr
== S_OK
, "failed to set subkey %08x\n", hr
);
857 method
= SysAllocString( enumkeyW
);
858 hr
= IWbemServices_ExecMethod( services
, class, method
, 0, NULL
, in
, &out
, NULL
);
859 ok( hr
== S_OK
, "failed to execute method %08x\n", hr
);
860 SysFreeString( method
);
863 VariantInit( &retval
);
864 hr
= IWbemClassObject_Get( out
, returnvalueW
, 0, &retval
, &type
, NULL
);
865 ok( hr
== S_OK
, "failed to get return value %08x\n", hr
);
866 ok( V_VT( &retval
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &retval
) );
867 ok( !V_I4( &retval
), "unexpected error %u\n", V_UI4( &retval
) );
868 ok( type
== CIM_UINT32
, "unexpected type 0x%x\n", type
);
871 VariantInit( &names
);
872 hr
= IWbemClassObject_Get( out
, namesW
, 0, &names
, &type
, NULL
);
873 ok( hr
== S_OK
, "failed to get names %08x\n", hr
);
874 ok( V_VT( &names
) == (VT_BSTR
|VT_ARRAY
), "unexpected variant type 0x%x\n", V_VT( &names
) );
875 ok( type
== (CIM_STRING
|CIM_FLAG_ARRAY
), "unexpected type 0x%x\n", type
);
877 VariantClear( &names
);
878 VariantClear( &subkey
);
879 IWbemClassObject_Release( in
);
880 IWbemClassObject_Release( out
);
881 IWbemClassObject_Release( sig_in
);
883 hr
= IWbemClassObject_GetMethod( reg
, enumvaluesW
, 0, &sig_in
, NULL
);
884 ok( hr
== S_OK
, "failed to get EnumValues method %08x\n", hr
);
886 hr
= IWbemClassObject_SpawnInstance( sig_in
, 0, &in
);
887 ok( hr
== S_OK
, "failed to spawn instance %08x\n", hr
);
889 V_VT( &defkey
) = VT_I4
;
890 V_I4( &defkey
) = 0x80000002;
891 hr
= IWbemClassObject_Put( in
, defkeyW
, 0, &defkey
, 0 );
892 ok( hr
== S_OK
, "failed to set root %08x\n", hr
);
894 V_VT( &subkey
) = VT_BSTR
;
895 V_BSTR( &subkey
) = SysAllocString( windowsW
);
896 hr
= IWbemClassObject_Put( in
, subkeynameW
, 0, &subkey
, 0 );
897 ok( hr
== S_OK
, "failed to set subkey %08x\n", hr
);
900 method
= SysAllocString( enumvaluesW
);
901 hr
= IWbemServices_ExecMethod( services
, class, method
, 0, NULL
, in
, &out
, NULL
);
902 ok( hr
== S_OK
, "failed to execute method %08x\n", hr
);
903 SysFreeString( method
);
906 VariantInit( &retval
);
907 hr
= IWbemClassObject_Get( out
, returnvalueW
, 0, &retval
, &type
, NULL
);
908 ok( hr
== S_OK
, "failed to get return value %08x\n", hr
);
909 ok( V_VT( &retval
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &retval
) );
910 ok( !V_I4( &retval
), "unexpected error %u\n", V_I4( &retval
) );
911 ok( type
== CIM_UINT32
, "unexpected type 0x%x\n", type
);
914 VariantInit( &names
);
915 hr
= IWbemClassObject_Get( out
, namesW
, 0, &names
, &type
, NULL
);
916 ok( hr
== S_OK
, "failed to get names %08x\n", hr
);
917 ok( V_VT( &names
) == (VT_BSTR
|VT_ARRAY
), "unexpected variant type 0x%x\n", V_VT( &names
) );
918 ok( type
== (CIM_STRING
|CIM_FLAG_ARRAY
), "unexpected type 0x%x\n", type
);
921 VariantInit( &types
);
922 hr
= IWbemClassObject_Get( out
, typesW
, 0, &types
, &type
, NULL
);
923 ok( hr
== S_OK
, "failed to get names %08x\n", hr
);
924 ok( V_VT( &types
) == (VT_I4
|VT_ARRAY
), "unexpected variant type 0x%x\n", V_VT( &types
) );
925 ok( type
== (CIM_SINT32
|CIM_FLAG_ARRAY
), "unexpected type 0x%x\n", type
);
927 VariantClear( &types
);
928 VariantClear( &names
);
929 VariantClear( &subkey
);
930 IWbemClassObject_Release( in
);
931 IWbemClassObject_Release( out
);
932 IWbemClassObject_Release( sig_in
);
934 hr
= IWbemClassObject_GetMethod( reg
, getstringvalueW
, 0, &sig_in
, NULL
);
935 ok( hr
== S_OK
, "failed to get GetStringValue method %08x\n", hr
);
937 hr
= IWbemClassObject_SpawnInstance( sig_in
, 0, &in
);
938 ok( hr
== S_OK
, "failed to spawn instance %08x\n", hr
);
940 V_VT( &defkey
) = VT_I4
;
941 V_I4( &defkey
) = 0x80000002;
942 hr
= IWbemClassObject_Put( in
, defkeyW
, 0, &defkey
, 0 );
943 ok( hr
== S_OK
, "failed to set root %08x\n", hr
);
945 V_VT( &subkey
) = VT_BSTR
;
946 V_BSTR( &subkey
) = SysAllocString( windowsW
);
947 hr
= IWbemClassObject_Put( in
, subkeynameW
, 0, &subkey
, 0 );
948 ok( hr
== S_OK
, "failed to set subkey %08x\n", hr
);
950 V_VT( &valuename
) = VT_BSTR
;
951 V_BSTR( &valuename
) = SysAllocString( programfilesW
);
952 hr
= IWbemClassObject_Put( in
, valuenameW
, 0, &valuename
, 0 );
953 ok( hr
== S_OK
, "failed to set value name %08x\n", hr
);
956 method
= SysAllocString( getstringvalueW
);
957 hr
= IWbemServices_ExecMethod( services
, class, method
, 0, NULL
, in
, &out
, NULL
);
958 ok( hr
== S_OK
, "failed to execute method %08x\n", hr
);
959 SysFreeString( method
);
962 VariantInit( &retval
);
963 hr
= IWbemClassObject_Get( out
, returnvalueW
, 0, &retval
, &type
, NULL
);
964 ok( hr
== S_OK
, "failed to get return value %08x\n", hr
);
965 ok( V_VT( &retval
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &retval
) );
966 ok( !V_I4( &retval
), "unexpected error %u\n", V_I4( &retval
) );
967 ok( type
== CIM_UINT32
, "unexpected type 0x%x\n", type
);
970 VariantInit( &value
);
971 hr
= IWbemClassObject_Get( out
, valueW
, 0, &value
, &type
, NULL
);
972 ok( hr
== S_OK
, "failed to get value %08x\n", hr
);
973 ok( V_VT( &value
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &value
) );
974 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
976 VariantClear( &value
);
977 VariantClear( &valuename
);
978 VariantClear( &subkey
);
979 IWbemClassObject_Release( in
);
980 IWbemClassObject_Release( out
);
981 IWbemClassObject_Release( sig_in
);
983 IWbemClassObject_Release( reg
);
984 SysFreeString( class );
987 static HRESULT WINAPI
sink_QueryInterface(
988 IWbemObjectSink
*iface
, REFIID riid
, void **ppv
)
991 if (IsEqualGUID( &IID_IUnknown
, riid
) || IsEqualGUID( &IID_IWbemObjectSink
, riid
))
994 IWbemObjectSink_AddRef( iface
);
997 return E_NOINTERFACE
;
1000 static ULONG sink_refs
;
1002 static ULONG WINAPI
sink_AddRef(
1003 IWbemObjectSink
*iface
)
1008 static ULONG WINAPI
sink_Release(
1009 IWbemObjectSink
*iface
)
1014 static HRESULT WINAPI
sink_Indicate(
1015 IWbemObjectSink
*iface
, LONG count
, IWbemClassObject
**objects
)
1017 trace("Indicate: %d, %p\n", count
, objects
);
1021 static HRESULT WINAPI
sink_SetStatus(
1022 IWbemObjectSink
*iface
, LONG flags
, HRESULT hresult
, BSTR str_param
, IWbemClassObject
*obj_param
)
1024 trace("SetStatus: %08x, %08x, %s, %p\n", flags
, hresult
, wine_dbgstr_w(str_param
), obj_param
);
1028 static IWbemObjectSinkVtbl sink_vtbl
=
1030 sink_QueryInterface
,
1037 static IWbemObjectSink sink
= { &sink_vtbl
};
1039 static void test_notification_query_async( IWbemServices
*services
)
1041 static const WCHAR queryW
[] =
1042 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
1043 'D','e','v','i','c','e','C','h','a','n','g','e','E','v','e','n','t',0};
1044 BSTR wql
= SysAllocString( wqlW
), query
= SysAllocString( queryW
);
1045 ULONG prev_sink_refs
;
1048 hr
= IWbemServices_ExecNotificationQueryAsync( services
, wql
, query
, 0, NULL
, NULL
);
1049 ok( hr
== WBEM_E_INVALID_PARAMETER
, "got %08x\n", hr
);
1051 prev_sink_refs
= sink_refs
;
1052 hr
= IWbemServices_ExecNotificationQueryAsync( services
, wql
, query
, 0, NULL
, &sink
);
1053 ok( hr
== S_OK
|| broken(hr
== WBEM_E_NOT_FOUND
), "got %08x\n", hr
);
1054 ok( sink_refs
> prev_sink_refs
|| broken(!sink_refs
), "got %u refs\n", sink_refs
);
1056 hr
= IWbemServices_CancelAsyncCall( services
, &sink
);
1057 ok( hr
== S_OK
|| broken(hr
== WBEM_E_NOT_FOUND
), "got %08x\n", hr
);
1059 SysFreeString( wql
);
1060 SysFreeString( query
);
1063 static void test_query_async( IWbemServices
*services
)
1065 static const WCHAR queryW
[] =
1066 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
1067 'P','r','o','c','e','s','s',0};
1068 BSTR wql
= SysAllocString( wqlW
), query
= SysAllocString( queryW
);
1071 hr
= IWbemServices_ExecQueryAsync( services
, wql
, query
, 0, NULL
, NULL
);
1072 ok( hr
== WBEM_E_INVALID_PARAMETER
, "got %08x\n", hr
);
1074 hr
= IWbemServices_ExecQueryAsync( services
, wql
, query
, 0, NULL
, &sink
);
1075 ok( hr
== S_OK
|| broken(hr
== WBEM_E_NOT_FOUND
), "got %08x\n", hr
);
1077 hr
= IWbemServices_CancelAsyncCall( services
, NULL
);
1078 ok( hr
== WBEM_E_INVALID_PARAMETER
, "got %08x\n", hr
);
1080 hr
= IWbemServices_CancelAsyncCall( services
, &sink
);
1081 ok( hr
== S_OK
, "got %08x\n", hr
);
1083 SysFreeString( wql
);
1084 SysFreeString( query
);
1087 static void test_query_semisync( IWbemServices
*services
)
1089 static const WCHAR queryW
[] =
1090 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_','D','u','m','m','y',0};
1091 BSTR wql
= SysAllocString( wqlW
), query
= SysAllocString( queryW
);
1092 IEnumWbemClassObject
*result
;
1093 IWbemClassObject
*obj
;
1097 hr
= IWbemServices_ExecQuery( services
, wql
, query
, WBEM_FLAG_RETURN_IMMEDIATELY
| WBEM_FLAG_FORWARD_ONLY
,
1099 ok( hr
== S_OK
, "got %08x\n", hr
);
1102 obj
= (void *)0xdeadbeef;
1103 hr
= IEnumWbemClassObject_Next( result
, -1, 1, &obj
, &count
);
1105 ok( hr
== WBEM_E_INVALID_CLASS
, "Unexpected hr %#x.\n", hr
);
1106 ok( count
== 0, "Unexpected count %u.\n", count
);
1107 ok( obj
== (void *)0xdeadbeef, "Got object %p\n", obj
);
1109 IEnumWbemClassObject_Release( result
);
1111 SysFreeString( wql
);
1112 SysFreeString( query
);
1115 static void test_GetNames( IWbemServices
*services
)
1117 static const WCHAR queryW
[] =
1118 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
1119 'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
1120 BSTR wql
= SysAllocString( wqlW
), query
= SysAllocString( queryW
);
1121 IEnumWbemClassObject
*result
;
1124 hr
= IWbemServices_ExecQuery( services
, wql
, query
, 0, NULL
, &result
);
1125 ok( hr
== S_OK
, "got %08x\n", hr
);
1129 IWbemClassObject
*obj
;
1134 IEnumWbemClassObject_Next( result
, 10000, 1, &obj
, &count
);
1137 VariantInit( &val
);
1138 hr
= IWbemClassObject_GetNames( obj
, NULL
, WBEM_FLAG_NONSYSTEM_ONLY
, &val
, &names
);
1139 ok( hr
== S_OK
, "got %08x\n", hr
);
1141 SafeArrayDestroy( names
);
1142 IWbemClassObject_Release( obj
);
1144 IEnumWbemClassObject_Release( result
);
1145 SysFreeString( query
);
1146 SysFreeString( wql
);
1149 static void test_SystemSecurity( IWbemServices
*services
)
1151 static const WCHAR systemsecurityW
[] = {'_','_','S','y','s','t','e','m','S','e','c','u','r','i','t','y',0};
1152 static const WCHAR getsdW
[] = {'G','e','t','S','D',0};
1153 static const WCHAR returnvalueW
[] = {'R','e','t','u','r','n','V','a','l','u','e',0};
1154 static const WCHAR sdW
[] = {'S','D',0};
1155 BSTR
class = SysAllocString( systemsecurityW
), method
;
1156 IWbemClassObject
*reg
, *out
;
1157 VARIANT retval
, var_sd
;
1159 SECURITY_DESCRIPTOR_RELATIVE
*sd
;
1162 BYTE sid_admin_buffer
[SECURITY_MAX_SID_SIZE
];
1163 SID
*sid_admin
= (SID
*)sid_admin_buffer
;
1167 hr
= IWbemServices_GetObject( services
, class, 0, NULL
, ®
, NULL
);
1170 win_skip( "__SystemSecurity not available\n" );
1173 IWbemClassObject_Release( reg
);
1175 sid_size
= sizeof(sid_admin_buffer
);
1176 ret
= CreateWellKnownSid( WinBuiltinAdministratorsSid
, NULL
, sid_admin
, &sid_size
);
1177 ok( ret
, "CreateWellKnownSid failed\n" );
1180 method
= SysAllocString( getsdW
);
1181 hr
= IWbemServices_ExecMethod( services
, class, method
, 0, NULL
, NULL
, &out
, NULL
);
1182 ok( hr
== S_OK
|| hr
== WBEM_E_ACCESS_DENIED
, "failed to execute method %08x\n", hr
);
1183 SysFreeString( method
);
1188 VariantInit( &retval
);
1189 hr
= IWbemClassObject_Get( out
, returnvalueW
, 0, &retval
, &type
, NULL
);
1190 ok( hr
== S_OK
, "failed to get return value %08x\n", hr
);
1191 ok( V_VT( &retval
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &retval
) );
1192 ok( !V_I4( &retval
), "unexpected error %u\n", V_UI4( &retval
) );
1193 ok( type
== CIM_UINT32
, "unexpected type 0x%x\n", type
);
1196 VariantInit( &var_sd
);
1197 hr
= IWbemClassObject_Get( out
, sdW
, 0, &var_sd
, &type
, NULL
);
1198 ok( hr
== S_OK
, "failed to get names %08x\n", hr
);
1199 ok( V_VT( &var_sd
) == (VT_UI1
|VT_ARRAY
), "unexpected variant type 0x%x\n", V_VT( &var_sd
) );
1200 ok( type
== (CIM_UINT8
|CIM_FLAG_ARRAY
), "unexpected type 0x%x\n", type
);
1202 hr
= SafeArrayAccessData( V_ARRAY( &var_sd
), &data
);
1203 ok( hr
== S_OK
, "SafeArrayAccessData failed %x\n", hr
);
1208 ok( (sd
->Control
& SE_SELF_RELATIVE
) == SE_SELF_RELATIVE
, "relative flag unset\n" );
1209 ok( sd
->Owner
!= 0, "no owner SID\n");
1210 ok( sd
->Group
!= 0, "no owner SID\n");
1211 ok( EqualSid( (PSID
)((LPBYTE
)sd
+ sd
->Owner
), sid_admin
), "unexpected owner SID\n" );
1212 ok( EqualSid( (PSID
)((LPBYTE
)sd
+ sd
->Group
), sid_admin
), "unexpected group SID\n" );
1214 hr
= SafeArrayUnaccessData( V_ARRAY( &var_sd
) );
1215 ok( hr
== S_OK
, "SafeArrayUnaccessData failed %x\n", hr
);
1218 VariantClear( &var_sd
);
1219 IWbemClassObject_Release( out
);
1221 else if (hr
== WBEM_E_ACCESS_DENIED
)
1222 win_skip( "insufficient privs to test __SystemSecurity\n" );
1224 SysFreeString( class );
1227 static void test_Win32_OperatingSystem( IWbemServices
*services
)
1229 static const WCHAR queryW
[] =
1230 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
1231 'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
1232 static const WCHAR buildnumberW
[] = {'B','u','i','l','d','N','u','m','b','e','r',0};
1233 static const WCHAR captionW
[] = {'C','a','p','t','i','o','n',0};
1234 static const WCHAR csdversionW
[] = {'C','S','D','V','e','r','s','i','o','n',0};
1235 static const WCHAR freephysicalmemoryW
[] = {'F','r','e','e','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
1236 static const WCHAR nameW
[] = {'N','a','m','e',0};
1237 static const WCHAR osproductsuiteW
[] = {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
1238 static const WCHAR ostypeW
[] = {'O','S','T','y','p','e',0};
1239 static const WCHAR suitemaskW
[] = {'S','u','i','t','e','M','a','s','k',0};
1240 static const WCHAR versionW
[] = {'V','e','r','s','i','o','n',0};
1241 static const WCHAR servicepackmajorW
[] =
1242 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
1243 static const WCHAR servicepackminorW
[] =
1244 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
1245 static const WCHAR totalvisiblememorysizeW
[] =
1246 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
1247 static const WCHAR totalvirtualmemorysizeW
[] =
1248 {'T','o','t','a','l','V','i','r','t','u','a','l','M','e','m','o','r','y','S','i','z','e',0};
1249 BSTR wql
= SysAllocString( wqlW
), query
= SysAllocString( queryW
);
1250 IEnumWbemClassObject
*result
;
1251 IWbemClassObject
*obj
;
1257 hr
= IWbemServices_ExecQuery( services
, wql
, query
, 0, NULL
, &result
);
1258 ok( hr
== S_OK
, "IWbemServices_ExecQuery failed %08x\n", hr
);
1260 hr
= IEnumWbemClassObject_Next( result
, 10000, 1, &obj
, &count
);
1261 ok( hr
== S_OK
, "IEnumWbemClassObject_Next failed %08x\n", hr
);
1263 hr
= IWbemClassObject_BeginEnumeration( obj
, 0 );
1264 ok( hr
== S_OK
, "got %08x\n", hr
);
1266 while (IWbemClassObject_Next( obj
, 0, NULL
, NULL
, NULL
, NULL
) == S_OK
) {}
1268 hr
= IWbemClassObject_EndEnumeration( obj
);
1269 ok( hr
== S_OK
, "got %08x\n", hr
);
1272 VariantInit( &val
);
1273 hr
= IWbemClassObject_Get( obj
, buildnumberW
, 0, &val
, &type
, NULL
);
1274 ok( hr
== S_OK
, "failed to get buildnumber %08x\n", hr
);
1275 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1276 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1277 trace( "buildnumber: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1278 VariantClear( &val
);
1281 VariantInit( &val
);
1282 hr
= IWbemClassObject_Get( obj
, captionW
, 0, &val
, &type
, NULL
);
1283 ok( hr
== S_OK
, "failed to get caption %08x\n", hr
);
1284 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1285 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1286 trace( "caption: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1287 VariantClear( &val
);
1290 VariantInit( &val
);
1291 hr
= IWbemClassObject_Get( obj
, csdversionW
, 0, &val
, &type
, NULL
);
1292 ok( hr
== S_OK
, "failed to get csdversion %08x\n", hr
);
1293 ok( V_VT( &val
) == VT_BSTR
|| V_VT( &val
) == VT_NULL
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1294 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1295 trace( "csdversion: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1296 VariantClear( &val
);
1299 VariantInit( &val
);
1300 hr
= IWbemClassObject_Get( obj
, freephysicalmemoryW
, 0, &val
, &type
, NULL
);
1301 ok( hr
== S_OK
, "failed to get free physical memory size %08x\n", hr
);
1302 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1303 ok( type
== CIM_UINT64
, "unexpected type 0x%x\n", type
);
1304 trace( "freephysicalmemory %s\n", wine_dbgstr_w(V_BSTR(&val
)) );
1305 VariantClear( &val
);
1308 VariantInit( &val
);
1309 hr
= IWbemClassObject_Get( obj
, nameW
, 0, &val
, &type
, NULL
);
1310 ok( hr
== S_OK
, "failed to get name %08x\n", hr
);
1311 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1312 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1313 trace( "name: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1314 VariantClear( &val
);
1317 VariantInit( &val
);
1318 hr
= IWbemClassObject_Get( obj
, osproductsuiteW
, 0, &val
, &type
, NULL
);
1319 ok( hr
== S_OK
, "failed to get osproductsuite %08x\n", hr
);
1320 ok( V_VT( &val
) == VT_I4
|| broken(V_VT( &val
) == VT_NULL
) /* winxp */, "unexpected variant type 0x%x\n", V_VT( &val
) );
1321 ok( type
== CIM_UINT32
, "unexpected type 0x%x\n", type
);
1322 trace( "osproductsuite: %d (%08x)\n", V_I4( &val
), V_I4( &val
) );
1323 VariantClear( &val
);
1326 VariantInit( &val
);
1327 hr
= IWbemClassObject_Get( obj
, ostypeW
, 0, &val
, &type
, NULL
);
1328 ok( hr
== S_OK
, "failed to get ostype %08x\n", hr
);
1329 ok( V_VT( &val
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1330 ok( type
== CIM_UINT16
, "unexpected type 0x%x\n", type
);
1331 trace( "ostype: %d\n", V_I4( &val
) );
1332 VariantClear( &val
);
1335 VariantInit( &val
);
1336 hr
= IWbemClassObject_Get( obj
, servicepackmajorW
, 0, &val
, &type
, NULL
);
1337 ok( hr
== S_OK
, "failed to get servicepackmajor %08x\n", hr
);
1338 ok( V_VT( &val
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1339 ok( type
== CIM_UINT16
, "unexpected type 0x%x\n", type
);
1340 trace( "servicepackmajor: %d\n", V_I4( &val
) );
1341 VariantClear( &val
);
1344 VariantInit( &val
);
1345 hr
= IWbemClassObject_Get( obj
, servicepackminorW
, 0, &val
, &type
, NULL
);
1346 ok( hr
== S_OK
, "failed to get servicepackminor %08x\n", hr
);
1347 ok( V_VT( &val
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1348 ok( type
== CIM_UINT16
, "unexpected type 0x%x\n", type
);
1349 trace( "servicepackminor: %d\n", V_I4( &val
) );
1350 VariantClear( &val
);
1353 VariantInit( &val
);
1354 hr
= IWbemClassObject_Get( obj
, suitemaskW
, 0, &val
, &type
, NULL
);
1355 ok( hr
== S_OK
, "failed to get suitemask %08x\n", hr
);
1356 ok( V_VT( &val
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1357 ok( type
== CIM_UINT32
, "unexpected type 0x%x\n", type
);
1358 trace( "suitemask: %d (%08x)\n", V_I4( &val
), V_I4( &val
) );
1359 VariantClear( &val
);
1362 VariantInit( &val
);
1363 hr
= IWbemClassObject_Get( obj
, versionW
, 0, &val
, &type
, NULL
);
1364 ok( hr
== S_OK
, "failed to get version %08x\n", hr
);
1365 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1366 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1367 trace( "version: %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1368 VariantClear( &val
);
1371 VariantInit( &val
);
1372 hr
= IWbemClassObject_Get( obj
, totalvisiblememorysizeW
, 0, &val
, &type
, NULL
);
1373 ok( hr
== S_OK
, "failed to get visible memory size %08x\n", hr
);
1374 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1375 ok( type
== CIM_UINT64
, "unexpected type 0x%x\n", type
);
1376 trace( "totalvisiblememorysize %s\n", wine_dbgstr_w(V_BSTR(&val
)) );
1377 VariantClear( &val
);
1380 VariantInit( &val
);
1381 hr
= IWbemClassObject_Get( obj
, totalvirtualmemorysizeW
, 0, &val
, &type
, NULL
);
1382 ok( hr
== S_OK
, "failed to get virtual memory size %08x\n", hr
);
1383 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1384 ok( type
== CIM_UINT64
, "unexpected type 0x%x\n", type
);
1385 trace( "totalvirtualmemorysize %s\n", wine_dbgstr_w(V_BSTR(&val
)) );
1386 VariantClear( &val
);
1388 IWbemClassObject_Release( obj
);
1389 IEnumWbemClassObject_Release( result
);
1390 SysFreeString( query
);
1391 SysFreeString( wql
);
1394 static void test_Win32_ComputerSystemProduct( IWbemServices
*services
)
1396 static const WCHAR identifyingnumberW
[] =
1397 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
1398 static const WCHAR nameW
[] =
1399 {'N','a','m','e',0};
1400 static const WCHAR skunumberW
[] =
1401 {'S','K','U','N','u','m','b','e','r',0};
1402 static const WCHAR uuidW
[] =
1403 {'U','U','I','D',0};
1404 static const WCHAR vendorW
[] =
1405 {'V','e','n','d','o','r',0};
1406 static const WCHAR versionW
[] =
1407 {'V','e','r','s','i','o','n',0};
1408 static const WCHAR queryW
[] =
1409 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
1410 'C','o','m','p','u','t','e','r','S','y','s','t','e','m','P','r','o','d','u','c','t',0};
1411 BSTR wql
= SysAllocString( wqlW
), query
= SysAllocString( queryW
);
1412 IEnumWbemClassObject
*result
;
1413 IWbemClassObject
*obj
;
1419 hr
= IWbemServices_ExecQuery( services
, wql
, query
, 0, NULL
, &result
);
1422 win_skip( "Win32_ComputerSystemProduct not available\n" );
1426 hr
= IEnumWbemClassObject_Next( result
, 10000, 1, &obj
, &count
);
1427 ok( hr
== S_OK
, "got %08x\n", hr
);
1430 VariantInit( &value
);
1431 hr
= IWbemClassObject_Get( obj
, identifyingnumberW
, 0, &value
, &type
, NULL
);
1432 ok( hr
== S_OK
, "got %08x\n", hr
);
1433 ok( V_VT( &value
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &value
) );
1434 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1435 trace( "identifyingnumber %s\n", wine_dbgstr_w(V_BSTR(&value
)) );
1436 VariantClear( &value
);
1439 VariantInit( &value
);
1440 hr
= IWbemClassObject_Get( obj
, nameW
, 0, &value
, &type
, NULL
);
1441 ok( hr
== S_OK
, "got %08x\n", hr
);
1442 ok( V_VT( &value
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &value
) );
1443 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1444 trace( "name %s\n", wine_dbgstr_w(V_BSTR(&value
)) );
1445 VariantClear( &value
);
1448 VariantInit( &value
);
1449 hr
= IWbemClassObject_Get( obj
, skunumberW
, 0, &value
, &type
, NULL
);
1450 ok( hr
== S_OK
, "got %08x\n", hr
);
1451 ok( V_VT( &value
) == VT_NULL
, "unexpected variant type 0x%x\n", V_VT( &value
) );
1452 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1453 VariantClear( &value
);
1456 VariantInit( &value
);
1457 hr
= IWbemClassObject_Get( obj
, uuidW
, 0, &value
, &type
, NULL
);
1458 ok( hr
== S_OK
, "got %08x\n", hr
);
1459 ok( V_VT( &value
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &value
) );
1460 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1461 trace( "uuid %s\n", wine_dbgstr_w(V_BSTR(&value
)) );
1462 VariantClear( &value
);
1465 VariantInit( &value
);
1466 hr
= IWbemClassObject_Get( obj
, vendorW
, 0, &value
, &type
, NULL
);
1467 ok( hr
== S_OK
, "got %08x\n", hr
);
1468 ok( V_VT( &value
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &value
) );
1469 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1470 trace( "vendor %s\n", wine_dbgstr_w(V_BSTR(&value
)) );
1471 VariantClear( &value
);
1474 VariantInit( &value
);
1475 hr
= IWbemClassObject_Get( obj
, versionW
, 0, &value
, &type
, NULL
);
1476 ok( hr
== S_OK
, "got %08x\n", hr
);
1477 ok( V_VT( &value
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &value
) );
1478 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1479 trace( "version %s\n", wine_dbgstr_w(V_BSTR(&value
)) );
1480 VariantClear( &value
);
1482 IWbemClassObject_Release( obj
);
1483 IEnumWbemClassObject_Release( result
);
1484 SysFreeString( query
);
1485 SysFreeString( wql
);
1488 static void test_Win32_PhysicalMemory( IWbemServices
*services
)
1490 static const WCHAR capacityW
[] = {'C','a','p','a','c','i','t','y',0};
1491 static const WCHAR memorytypeW
[] = {'M','e','m','o','r','y','T','y','p','e',0};
1492 static const WCHAR queryW
[] =
1493 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
1494 'P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
1495 BSTR wql
= SysAllocString( wqlW
), query
= SysAllocString( queryW
);
1496 IEnumWbemClassObject
*result
;
1497 IWbemClassObject
*obj
;
1503 hr
= IWbemServices_ExecQuery( services
, wql
, query
, 0, NULL
, &result
);
1506 win_skip( "Win32_PhysicalMemory not available\n" );
1510 hr
= IEnumWbemClassObject_Next( result
, 10000, 1, &obj
, &count
);
1511 ok( hr
== S_OK
, "got %08x\n", hr
);
1516 VariantInit( &val
);
1517 hr
= IWbemClassObject_Get( obj
, capacityW
, 0, &val
, &type
, NULL
);
1518 ok( hr
== S_OK
, "failed to get capacity %08x\n", hr
);
1519 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1520 ok( type
== CIM_UINT64
, "unexpected type 0x%x\n", type
);
1521 trace( "capacity %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1522 VariantClear( &val
);
1525 VariantInit( &val
);
1526 hr
= IWbemClassObject_Get( obj
, memorytypeW
, 0, &val
, &type
, NULL
);
1527 ok( hr
== S_OK
, "failed to get memory type %08x\n", hr
);
1528 ok( V_VT( &val
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1529 ok( type
== CIM_UINT16
, "unexpected type 0x%x\n", type
);
1530 trace( "memorytype %u\n", V_I4( &val
) );
1531 VariantClear( &val
);
1533 IWbemClassObject_Release( obj
);
1535 IEnumWbemClassObject_Release( result
);
1536 SysFreeString( query
);
1537 SysFreeString( wql
);
1540 static void test_Win32_IP4RouteTable( IWbemServices
*services
)
1542 static const WCHAR destinationW
[] = {'D','e','s','t','i','n','a','t','i','o','n',0};
1543 static const WCHAR interfaceindexW
[] = {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
1544 static const WCHAR nexthopW
[] = {'N','e','x','t','H','o','p',0};
1545 static const WCHAR queryW
[] =
1546 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
1547 'I','P','4','R','o','u','t','e','T','a','b','l','e',0};
1548 BSTR wql
= SysAllocString( wqlW
), query
= SysAllocString( queryW
);
1549 IEnumWbemClassObject
*result
;
1550 IWbemClassObject
*obj
;
1556 hr
= IWbemServices_ExecQuery( services
, wql
, query
, 0, NULL
, &result
);
1559 win_skip( "Win32_IP4RouteTable not available\n" );
1565 hr
= IEnumWbemClassObject_Next( result
, 10000, 1, &obj
, &count
);
1566 if (hr
!= S_OK
) break;
1569 VariantInit( &val
);
1570 hr
= IWbemClassObject_Get( obj
, destinationW
, 0, &val
, &type
, NULL
);
1571 ok( hr
== S_OK
, "failed to get destination %08x\n", hr
);
1572 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1573 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1574 trace( "destination %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1575 VariantClear( &val
);
1578 VariantInit( &val
);
1579 hr
= IWbemClassObject_Get( obj
, interfaceindexW
, 0, &val
, &type
, NULL
);
1580 ok( hr
== S_OK
, "failed to get interface index %08x\n", hr
);
1581 ok( V_VT( &val
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1582 ok( type
== CIM_SINT32
, "unexpected type 0x%x\n", type
);
1583 trace( "interfaceindex %d\n", V_I4( &val
) );
1584 VariantClear( &val
);
1587 VariantInit( &val
);
1588 hr
= IWbemClassObject_Get( obj
, nexthopW
, 0, &val
, &type
, NULL
);
1589 ok( hr
== S_OK
, "failed to get nexthop %08x\n", hr
);
1590 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1591 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1592 trace( "nexthop %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1593 VariantClear( &val
);
1595 IWbemClassObject_Release( obj
);
1598 IEnumWbemClassObject_Release( result
);
1599 SysFreeString( query
);
1600 SysFreeString( wql
);
1603 static void test_Win32_Processor( IWbemServices
*services
)
1605 static const WCHAR architectureW
[] =
1606 {'A','r','c','h','i','t','e','c','t','u','r','e',0};
1607 static const WCHAR captionW
[] =
1608 {'C','a','p','t','i','o','n',0};
1609 static const WCHAR familyW
[] =
1610 {'F','a','m','i','l','y',0};
1611 static const WCHAR levelW
[] =
1612 {'L','e','v','e','l',0};
1613 static const WCHAR manufacturerW
[] =
1614 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
1615 static const WCHAR nameW
[] =
1616 {'N','a','m','e',0};
1617 static const WCHAR numcoresW
[] =
1618 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
1619 static const WCHAR numlogicalprocessorsW
[] =
1620 {'N','u','m','b','e','r','O','f','L','o','g','i','c','a','l','P','r','o','c','e','s','s','o','r','s',0};
1621 static const WCHAR processoridW
[] =
1622 {'P','r','o','c','e','s','s','o','r','I','d',0};
1623 static const WCHAR revisionW
[] =
1624 {'R','e','v','i','s','i','o','n',0};
1625 static const WCHAR versionW
[] =
1626 {'V','e','r','s','i','o','n',0};
1627 static const WCHAR queryW
[] =
1628 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
1629 'P','r','o','c','e','s','s','o','r',0};
1630 BSTR wql
= SysAllocString( wqlW
), query
= SysAllocString( queryW
);
1631 IEnumWbemClassObject
*result
;
1632 IWbemClassObject
*obj
;
1638 hr
= IWbemServices_ExecQuery( services
, wql
, query
, 0, NULL
, &result
);
1639 ok( hr
== S_OK
, "got %08x\n", hr
);
1643 hr
= IEnumWbemClassObject_Next( result
, 10000, 1, &obj
, &count
);
1644 if (hr
!= S_OK
) break;
1647 VariantInit( &val
);
1648 hr
= IWbemClassObject_Get( obj
, captionW
, 0, &val
, &type
, NULL
);
1649 ok( hr
== S_OK
, "got %08x\n", hr
);
1650 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1651 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1652 trace( "caption %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1653 VariantClear( &val
);
1656 VariantInit( &val
);
1657 hr
= IWbemClassObject_Get( obj
, architectureW
, 0, &val
, &type
, NULL
);
1658 ok( hr
== S_OK
, "got %08x\n", hr
);
1659 ok( V_VT( &val
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1660 ok( type
== CIM_UINT16
, "unexpected type 0x%x\n", type
);
1661 trace( "architecture %u\n", V_I4( &val
) );
1664 VariantInit( &val
);
1665 hr
= IWbemClassObject_Get( obj
, familyW
, 0, &val
, &type
, NULL
);
1666 ok( hr
== S_OK
, "got %08x\n", hr
);
1667 ok( V_VT( &val
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1668 ok( type
== CIM_UINT16
, "unexpected type 0x%x\n", type
);
1669 trace( "family %u\n", V_I4( &val
) );
1672 VariantInit( &val
);
1673 hr
= IWbemClassObject_Get( obj
, levelW
, 0, &val
, &type
, NULL
);
1674 ok( hr
== S_OK
, "got %08x\n", hr
);
1675 ok( V_VT( &val
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1676 ok( type
== CIM_UINT16
, "unexpected type 0x%x\n", type
);
1677 trace( "level %u\n", V_I4( &val
) );
1680 VariantInit( &val
);
1681 hr
= IWbemClassObject_Get( obj
, manufacturerW
, 0, &val
, &type
, NULL
);
1682 ok( hr
== S_OK
, "got %08x\n", hr
);
1683 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1684 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1685 trace( "manufacturer %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1686 VariantClear( &val
);
1689 VariantInit( &val
);
1690 hr
= IWbemClassObject_Get( obj
, nameW
, 0, &val
, &type
, NULL
);
1691 ok( hr
== S_OK
, "got %08x\n", hr
);
1692 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1693 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1694 trace( "name %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1695 VariantClear( &val
);
1698 VariantInit( &val
);
1699 hr
= IWbemClassObject_Get( obj
, processoridW
, 0, &val
, &type
, NULL
);
1700 ok( hr
== S_OK
, "got %08x\n", hr
);
1701 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1702 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1703 trace( "processorid %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1704 VariantClear( &val
);
1707 VariantInit( &val
);
1708 hr
= IWbemClassObject_Get( obj
, revisionW
, 0, &val
, &type
, NULL
);
1709 ok( hr
== S_OK
, "got %08x\n", hr
);
1710 ok( V_VT( &val
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1711 ok( type
== CIM_UINT16
, "unexpected type 0x%x\n", type
);
1712 trace( "revision %u\n", V_I4( &val
) );
1715 VariantInit( &val
);
1716 hr
= IWbemClassObject_Get( obj
, versionW
, 0, &val
, &type
, NULL
);
1717 ok( hr
== S_OK
, "got %08x\n", hr
);
1718 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1719 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1720 trace( "version %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1721 VariantClear( &val
);
1724 VariantInit( &val
);
1725 hr
= IWbemClassObject_Get( obj
, numlogicalprocessorsW
, 0, &val
, &type
, NULL
);
1726 ok( hr
== S_OK
|| broken(hr
== WBEM_E_NOT_FOUND
) /* win2k3 */, "got %08x\n", hr
);
1729 ok( V_VT( &val
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1730 ok( type
== CIM_UINT32
, "unexpected type 0x%x\n", type
);
1731 trace( "numlogicalprocessors %u\n", V_I4( &val
) );
1735 VariantInit( &val
);
1736 hr
= IWbemClassObject_Get( obj
, numcoresW
, 0, &val
, &type
, NULL
);
1737 ok( hr
== S_OK
|| broken(hr
== WBEM_E_NOT_FOUND
) /* win2k3 */, "got %08x\n", hr
);
1740 ok( V_VT( &val
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1741 ok( type
== CIM_UINT32
, "unexpected type 0x%x\n", type
);
1742 trace( "numcores %u\n", V_I4( &val
) );
1745 IWbemClassObject_Release( obj
);
1748 IEnumWbemClassObject_Release( result
);
1749 SysFreeString( query
);
1750 SysFreeString( wql
);
1753 static void test_Win32_VideoController( IWbemServices
*services
)
1755 static const WCHAR configmanagererrorcodeW
[] =
1756 {'C','o','n','f','i','g','M','a','n','a','g','e','r','E','r','r','o','r','C','o','d','e',0};
1757 static const WCHAR driverdateW
[] =
1758 {'D','r','i','v','e','r','D','a','t','e',0};
1759 static const WCHAR installeddisplaydriversW
[]=
1760 {'I','n','s','t','a','l','l','e','d','D','i','s','p','l','a','y','D','r','i','v','e','r','s',0};
1761 static const WCHAR statusW
[] =
1762 {'S','t','a','t','u','s',0};
1763 static const WCHAR queryW
[] =
1764 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
1765 'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
1766 BSTR wql
= SysAllocString( wqlW
), query
= SysAllocString( queryW
);
1767 IEnumWbemClassObject
*result
;
1768 IWbemClassObject
*obj
;
1774 hr
= IWbemServices_ExecQuery( services
, wql
, query
, 0, NULL
, &result
);
1777 win_skip( "Win32_VideoController not available\n" );
1783 hr
= IEnumWbemClassObject_Next( result
, 10000, 1, &obj
, &count
);
1784 if (hr
!= S_OK
) break;
1787 VariantInit( &val
);
1788 hr
= IWbemClassObject_Get( obj
, configmanagererrorcodeW
, 0, &val
, &type
, NULL
);
1789 ok( hr
== S_OK
, "got %08x\n", hr
);
1790 ok( V_VT( &val
) == VT_I4
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1791 ok( type
== CIM_UINT32
, "unexpected type 0x%x\n", type
);
1792 trace( "configmanagererrorcode %d\n", V_I4( &val
) );
1795 VariantInit( &val
);
1796 hr
= IWbemClassObject_Get( obj
, driverdateW
, 0, &val
, &type
, NULL
);
1797 ok( hr
== S_OK
, "got %08x\n", hr
);
1798 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1799 ok( type
== CIM_DATETIME
, "unexpected type 0x%x\n", type
);
1800 trace( "driverdate %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1801 VariantClear( &val
);
1804 VariantInit( &val
);
1805 hr
= IWbemClassObject_Get( obj
, installeddisplaydriversW
, 0, &val
, &type
, NULL
);
1806 ok( hr
== S_OK
, "got %08x\n", hr
);
1807 ok( V_VT( &val
) == VT_BSTR
|| V_VT( &val
) == VT_NULL
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1808 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1809 trace( "installeddisplaydrivers %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1810 VariantClear( &val
);
1813 VariantInit( &val
);
1814 hr
= IWbemClassObject_Get( obj
, statusW
, 0, &val
, &type
, NULL
);
1815 ok( hr
== S_OK
, "got %08x\n", hr
);
1816 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1817 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1818 trace( "status %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1819 VariantClear( &val
);
1821 IWbemClassObject_Release( obj
);
1824 IEnumWbemClassObject_Release( result
);
1825 SysFreeString( query
);
1826 SysFreeString( wql
);
1829 static void test_Win32_Printer( IWbemServices
*services
)
1831 static const WCHAR deviceidW
[] =
1832 {'D','e','v','i','c','e','I','d',0};
1833 static const WCHAR locationW
[] =
1834 {'L','o','c','a','t','i','o','n',0};
1835 static const WCHAR portnameW
[] =
1836 {'P','o','r','t','N','a','m','e',0};
1837 static const WCHAR queryW
[] =
1838 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
1839 'P','r','i','n','t','e','r',0};
1840 BSTR wql
= SysAllocString( wqlW
), query
= SysAllocString( queryW
);
1841 IEnumWbemClassObject
*result
;
1842 IWbemClassObject
*obj
;
1848 hr
= IWbemServices_ExecQuery( services
, wql
, query
, 0, NULL
, &result
);
1851 win_skip( "Win32_Printer not available\n" );
1857 hr
= IEnumWbemClassObject_Next( result
, 10000, 1, &obj
, &count
);
1858 if (hr
!= S_OK
) break;
1861 memset( &val
, 0, sizeof(val
) );
1862 hr
= IWbemClassObject_Get( obj
, deviceidW
, 0, &val
, &type
, NULL
);
1863 ok( hr
== S_OK
, "got %08x\n", hr
);
1864 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1865 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1866 trace( "deviceid %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1867 VariantClear( &val
);
1870 memset( &val
, 0, sizeof(val
) );
1871 hr
= IWbemClassObject_Get( obj
, locationW
, 0, &val
, &type
, NULL
);
1872 ok( hr
== S_OK
, "got %08x\n", hr
);
1873 ok( V_VT( &val
) == VT_BSTR
|| V_VT( &val
) == VT_NULL
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1874 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1875 trace( "location %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1876 VariantClear( &val
);
1879 memset( &val
, 0, sizeof(val
) );
1880 hr
= IWbemClassObject_Get( obj
, portnameW
, 0, &val
, &type
, NULL
);
1881 ok( hr
== S_OK
, "got %08x\n", hr
);
1882 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1883 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1884 trace( "portname %s\n", wine_dbgstr_w(V_BSTR( &val
)) );
1885 VariantClear( &val
);
1887 IWbemClassObject_Release( obj
);
1890 IEnumWbemClassObject_Release( result
);
1891 SysFreeString( query
);
1892 SysFreeString( wql
);
1895 static void test_Win32_PnPEntity( IWbemServices
*services
)
1898 IEnumWbemClassObject
*enm
;
1899 IWbemClassObject
*obj
;
1905 static WCHAR win32_pnpentityW
[] = {'W','i','n','3','2','_','P','n','P','E','n','t','i','t','y',0};
1906 static const WCHAR deviceidW
[] = {'D','e','v','i','c','e','I','d',0};
1908 bstr
= SysAllocString( win32_pnpentityW
);
1910 hr
= IWbemServices_CreateInstanceEnum( services
, bstr
, 0, NULL
, &enm
);
1911 ok( hr
== S_OK
, "got %08x\n", hr
);
1913 SysFreeString( bstr
);
1914 bstr
= SysAllocString( deviceidW
);
1918 hr
= IEnumWbemClassObject_Next( enm
, 1000, 1, &obj
, &count
);
1919 ok( (count
== 1 && (hr
== WBEM_S_FALSE
|| hr
== WBEM_S_NO_ERROR
)) ||
1920 (count
== 0 && (hr
== WBEM_S_FALSE
|| hr
== WBEM_S_TIMEDOUT
)),
1921 "got %08x with %u objects returned\n", hr
, count
);
1926 for (i
= 0; i
< count
; ++i
)
1928 hr
= IWbemClassObject_Get( obj
, bstr
, 0, &val
, &type
, NULL
);
1929 ok( hr
== S_OK
, "got %08x\n", hr
);
1931 if (SUCCEEDED( hr
))
1933 ok( V_VT( &val
) == VT_BSTR
, "unexpected variant type 0x%x\n", V_VT( &val
) );
1934 ok( type
== CIM_STRING
, "unexpected type 0x%x\n", type
);
1935 VariantClear( &val
);
1940 SysFreeString( bstr
);
1942 IEnumWbemClassObject_Release( enm
);
1947 static const WCHAR cimv2W
[] = {'R','O','O','T','\\','C','I','M','V','2',0};
1948 BSTR path
= SysAllocString( cimv2W
);
1949 IWbemLocator
*locator
;
1950 IWbemServices
*services
;
1953 CoInitialize( NULL
);
1954 CoInitializeSecurity( NULL
, -1, NULL
, NULL
, RPC_C_AUTHN_LEVEL_DEFAULT
,
1955 RPC_C_IMP_LEVEL_IMPERSONATE
, NULL
, EOAC_NONE
, NULL
);
1956 hr
= CoCreateInstance( &CLSID_WbemLocator
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemLocator
,
1957 (void **)&locator
);
1960 win_skip("can't create instance of WbemLocator\n");
1963 hr
= IWbemLocator_ConnectServer( locator
, path
, NULL
, NULL
, NULL
, 0, NULL
, NULL
, &services
);
1964 ok( hr
== S_OK
, "failed to get IWbemServices interface %08x\n", hr
);
1966 hr
= CoSetProxyBlanket( (IUnknown
*)services
, RPC_C_AUTHN_WINNT
, RPC_C_AUTHZ_NONE
, NULL
,
1967 RPC_C_AUTHN_LEVEL_CALL
, RPC_C_IMP_LEVEL_IMPERSONATE
, NULL
, EOAC_NONE
);
1968 ok( hr
== S_OK
, "failed to set proxy blanket %08x\n", hr
);
1970 test_select( services
);
1971 test_associators( services
);
1972 test_Win32_Bios( services
);
1973 test_Win32_Process( services
, FALSE
);
1974 test_Win32_Process( services
, TRUE
);
1975 test_Win32_Service( services
);
1976 test_Win32_ComputerSystem( services
);
1977 test_Win32_SystemEnclosure( services
);
1978 test_StdRegProv( services
);
1979 test_notification_query_async( services
);
1980 test_query_async( services
);
1981 test_query_semisync( services
);
1982 test_GetNames( services
);
1983 test_SystemSecurity( services
);
1984 test_Win32_OperatingSystem( services
);
1985 test_Win32_ComputerSystemProduct( services
);
1986 test_Win32_PhysicalMemory( services
);
1987 test_Win32_IP4RouteTable( services
);
1988 test_Win32_Processor( services
);
1989 test_Win32_VideoController( services
);
1990 test_Win32_Printer( services
);
1991 test_Win32_PnPEntity( services
);
1993 SysFreeString( path
);
1994 IWbemServices_Release( services
);
1995 IWbemLocator_Release( locator
);