2 * Tests for pdh.dll (Performance Data Helper)
4 * Copyright 2007 Hans Leidekker
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wine/test.h"
32 static PDH_STATUS (WINAPI *pPdhAddEnglishCounterA)(PDH_HQUERY, LPCSTR, DWORD_PTR, PDH_HCOUNTER *);
33 static PDH_STATUS (WINAPI *pPdhAddEnglishCounterW)(PDH_HQUERY, LPCWSTR, DWORD_PTR, PDH_HCOUNTER *);
34 static PDH_STATUS (WINAPI *pPdhCollectQueryDataWithTime)(PDH_HQUERY, LONGLONG *);
35 static PDH_STATUS (WINAPI *pPdhValidatePathExA)(PDH_HLOG, LPCSTR);
36 static PDH_STATUS (WINAPI *pPdhValidatePathExW)(PDH_HLOG, LPCWSTR);
38 #define GETFUNCPTR(func) p##func = (void *)GetProcAddress( pdh, #func );
40 static void init_function_ptrs( void )
42 pdh = GetModuleHandle( "pdh" );
43 GETFUNCPTR( PdhAddEnglishCounterA )
44 GETFUNCPTR( PdhAddEnglishCounterW )
45 GETFUNCPTR( PdhCollectQueryDataWithTime )
46 GETFUNCPTR( PdhValidatePathExA )
47 GETFUNCPTR( PdhValidatePathExW )
50 static const WCHAR processor_time[] =
51 {'%',' ','P','r','o','c','e','s','s','o','r',' ','T','i','m','e',0};
52 static const WCHAR uptime[] =
53 {'S','y','s','t','e','m',' ','U','p',' ','T','i','m','e',0};
55 static const WCHAR system_uptime[] =
56 {'\\','S','y','s','t','e','m','\\','S','y','s','t','e','m',' ','U','p',' ','T','i','m','e',0};
57 static const WCHAR system_downtime[] = /* does not exist */
58 {'\\','S','y','s','t','e','m','\\','S','y','s','t','e','m',' ','D','o','w','n',' ','T','i','m','e',0};
59 static const WCHAR percentage_processor_time[] =
60 {'\\','P','r','o','c','e','s','s','o','r','(','_','T','o','t','a','l',')',
61 '\\','%',' ','P','r','o','c','e','s','s','o','r',' ','T','i','m','e',0};
63 static void test_PdhOpenQueryA( void )
68 ret = PdhOpenQueryA( NULL, 0, NULL );
69 ok(ret == PDH_INVALID_ARGUMENT, "PdhOpenQueryA failed 0x%08x\n", ret);
71 ret = PdhOpenQueryA( NULL, 0, &query );
72 ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret);
74 ret = PdhCloseQuery( NULL );
75 ok(ret == PDH_INVALID_HANDLE, "PdhCloseQuery failed 0x%08x\n", ret);
77 ret = PdhCloseQuery( &query );
78 ok(ret == PDH_INVALID_HANDLE, "PdhCloseQuery failed 0x%08x\n", ret);
80 ret = PdhCloseQuery( query );
81 ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret);
83 ret = PdhCloseQuery( query );
84 ok(ret == PDH_INVALID_HANDLE, "PdhCloseQuery failed 0x%08x\n", ret);
87 static void test_PdhOpenQueryW( void )
92 ret = PdhOpenQueryW( NULL, 0, NULL );
93 ok(ret == PDH_INVALID_ARGUMENT, "PdhOpenQueryW failed 0x%08x\n", ret);
95 ret = PdhOpenQueryW( NULL, 0, &query );
96 ok(ret == ERROR_SUCCESS, "PdhOpenQueryW failed 0x%08x\n", ret);
98 ret = PdhCloseQuery( NULL );
99 ok(ret == PDH_INVALID_HANDLE, "PdhCloseQuery failed 0x%08x\n", ret);
101 ret = PdhCloseQuery( &query );
102 ok(ret == PDH_INVALID_HANDLE, "PdhCloseQuery failed 0x%08x\n", ret);
104 ret = PdhCloseQuery( query );
105 ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret);
107 ret = PdhCloseQuery( query );
108 ok(ret == PDH_INVALID_HANDLE, "PdhCloseQuery failed 0x%08x\n", ret);
111 static void test_PdhAddCounterA( void )
115 PDH_HCOUNTER counter;
117 ret = PdhOpenQueryA( NULL, 0, &query );
118 ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret);
120 ret = PdhAddCounterA( NULL, "\\System\\System Up Time", 0, NULL );
121 ok(ret == PDH_INVALID_ARGUMENT, "PdhAddCounterA failed 0x%08x\n", ret);
123 ret = PdhAddCounterA( NULL, "\\System\\System Up Time", 0, &counter );
124 ok(ret == PDH_INVALID_HANDLE, "PdhAddCounterA failed 0x%08x\n", ret);
126 ret = PdhAddCounterA( query, NULL, 0, &counter );
127 ok(ret == PDH_INVALID_ARGUMENT, "PdhAddCounterA failed 0x%08x\n", ret);
129 ret = PdhAddCounterA( query, "\\System\\System Up Time", 0, NULL );
130 ok(ret == PDH_INVALID_ARGUMENT, "PdhAddCounterA failed 0x%08x\n", ret);
132 ret = PdhAddCounterA( query, "\\System\\System Down Time", 0, &counter );
133 ok(ret == PDH_CSTATUS_NO_COUNTER, "PdhAddCounterA failed 0x%08x\n", ret);
134 ok(!counter, "PdhAddCounterA failed %p\n", counter);
136 ret = PdhAddCounterA( query, "\\System\\System Up Time", 0, &counter );
137 ok(ret == ERROR_SUCCESS, "PdhAddCounterA failed 0x%08x\n", ret);
139 ret = PdhCollectQueryData( NULL );
140 ok(ret == PDH_INVALID_HANDLE, "PdhCollectQueryData failed 0x%08x\n", ret);
142 ret = PdhCollectQueryData( counter );
143 ok(ret == PDH_INVALID_HANDLE, "PdhCollectQueryData failed 0x%08x\n", ret);
145 ret = PdhCollectQueryData( query );
146 ok(ret == ERROR_SUCCESS, "PdhCollectQueryData failed 0x%08x\n", ret);
148 ret = PdhRemoveCounter( NULL );
149 ok(ret == PDH_INVALID_HANDLE, "PdhRemoveCounter failed 0x%08x\n", ret);
151 ret = PdhRemoveCounter( counter );
152 ok(ret == ERROR_SUCCESS, "PdhRemoveCounter failed 0x%08x\n", ret);
154 ret = PdhCloseQuery( query );
155 ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret);
158 static void test_PdhAddCounterW( void )
162 PDH_HCOUNTER counter;
164 ret = PdhOpenQueryW( NULL, 0, &query );
165 ok(ret == ERROR_SUCCESS, "PdhOpenQueryW failed 0x%08x\n", ret);
167 ret = PdhAddCounterW( NULL, percentage_processor_time, 0, NULL );
168 ok(ret == PDH_INVALID_ARGUMENT, "PdhAddCounterW failed 0x%08x\n", ret);
170 ret = PdhAddCounterW( NULL, percentage_processor_time, 0, &counter );
171 ok(ret == PDH_INVALID_HANDLE, "PdhAddCounterW failed 0x%08x\n", ret);
173 ret = PdhAddCounterW( query, NULL, 0, &counter );
174 ok(ret == PDH_INVALID_ARGUMENT, "PdhAddCounterW failed 0x%08x\n", ret);
176 ret = PdhAddCounterW( query, percentage_processor_time, 0, NULL );
177 ok(ret == PDH_INVALID_ARGUMENT, "PdhAddCounterW failed 0x%08x\n", ret);
179 ret = PdhAddCounterW( query, system_downtime, 0, &counter );
180 ok(ret == PDH_CSTATUS_NO_COUNTER, "PdhAddCounterW failed 0x%08x\n", ret);
181 ok(!counter, "PdhAddCounterW failed %p\n", counter);
183 ret = PdhAddCounterW( query, percentage_processor_time, 0, &counter );
184 ok(ret == ERROR_SUCCESS, "PdhAddCounterW failed 0x%08x\n", ret);
186 ret = PdhCollectQueryData( NULL );
187 ok(ret == PDH_INVALID_HANDLE, "PdhCollectQueryData failed 0x%08x\n", ret);
189 ret = PdhCollectQueryData( counter );
190 ok(ret == PDH_INVALID_HANDLE, "PdhCollectQueryData failed 0x%08x\n", ret);
192 ret = PdhCollectQueryData( query );
193 ok(ret == ERROR_SUCCESS, "PdhCollectQueryData failed 0x%08x\n", ret);
195 ret = PdhRemoveCounter( NULL );
196 ok(ret == PDH_INVALID_HANDLE, "PdhRemoveCounter failed 0x%08x\n", ret);
198 ret = PdhRemoveCounter( counter );
199 ok(ret == ERROR_SUCCESS, "PdhRemoveCounter failed 0x%08x\n", ret);
201 ret = PdhCloseQuery( query );
202 ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret);
205 static void test_PdhAddEnglishCounterA( void )
209 PDH_HCOUNTER counter;
211 ret = PdhOpenQueryA( NULL, 0, &query );
212 ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret);
214 ret = PdhCollectQueryData( query );
215 ok(ret == PDH_NO_DATA, "PdhCollectQueryData failed 0x%08x\n", ret);
217 ret = pPdhAddEnglishCounterA( NULL, "\\System\\System Up Time", 0, NULL );
218 ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterA failed 0x%08x\n", ret);
220 ret = pPdhAddEnglishCounterA( NULL, "\\System\\System Up Time", 0, &counter );
221 ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterA failed 0x%08x\n", ret);
223 ret = pPdhAddEnglishCounterA( query, NULL, 0, &counter );
224 ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterA failed 0x%08x\n", ret);
226 ret = pPdhAddEnglishCounterA( query, "\\System\\System Up Time", 0, NULL );
227 ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterA failed 0x%08x\n", ret);
229 ret = pPdhAddEnglishCounterA( query, "\\System\\System Down Time", 0, &counter );
230 ok(ret == PDH_CSTATUS_NO_COUNTER, "PdhAddEnglishCounterA failed 0x%08x\n", ret);
231 ok(!counter, "PdhAddEnglishCounterA failed %p\n", counter);
233 ret = pPdhAddEnglishCounterA( query, "\\System\\System Up Time", 0, &counter );
234 ok(ret == ERROR_SUCCESS, "PdhAddEnglishCounterA failed 0x%08x\n", ret);
236 ret = PdhCollectQueryData( query );
237 ok(ret == ERROR_SUCCESS, "PdhCollectQueryData failed 0x%08x\n", ret);
239 ret = PdhRemoveCounter( counter );
240 ok(ret == ERROR_SUCCESS, "PdhRemoveCounter failed 0x%08x\n", ret);
242 ret = PdhCloseQuery( query );
243 ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret);
246 static void test_PdhAddEnglishCounterW( void )
250 PDH_HCOUNTER counter;
252 ret = PdhOpenQueryW( NULL, 0, &query );
253 ok(ret == ERROR_SUCCESS, "PdhOpenQueryW failed 0x%08x\n", ret);
255 ret = PdhCollectQueryData( query );
256 ok(ret == PDH_NO_DATA, "PdhCollectQueryData failed 0x%08x\n", ret);
258 ret = pPdhAddEnglishCounterW( NULL, system_uptime, 0, NULL );
259 ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterW failed 0x%08x\n", ret);
261 ret = pPdhAddEnglishCounterW( NULL, system_uptime, 0, &counter );
262 ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterW failed 0x%08x\n", ret);
264 ret = pPdhAddEnglishCounterW( query, NULL, 0, &counter );
265 ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterW failed 0x%08x\n", ret);
267 ret = pPdhAddEnglishCounterW( query, system_uptime, 0, NULL );
268 ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterW failed 0x%08x\n", ret);
270 ret = pPdhAddEnglishCounterW( query, system_downtime, 0, &counter );
271 ok(ret == PDH_CSTATUS_NO_COUNTER, "PdhAddEnglishCounterW failed 0x%08x\n", ret);
272 ok(!counter, "PdhAddEnglishCounterA failed %p\n", counter);
274 ret = pPdhAddEnglishCounterW( query, system_uptime, 0, &counter );
275 ok(ret == ERROR_SUCCESS, "PdhAddEnglishCounterW failed 0x%08x\n", ret);
277 ret = PdhCollectQueryData( query );
278 ok(ret == ERROR_SUCCESS, "PdhCollectQueryData failed 0x%08x\n", ret);
280 ret = PdhRemoveCounter( counter );
281 ok(ret == ERROR_SUCCESS, "PdhRemoveCounter failed 0x%08x\n", ret);
283 ret = PdhCloseQuery( query );
284 ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret);
287 static void test_PdhCollectQueryDataWithTime( void )
291 PDH_HCOUNTER counter;
294 ret = PdhOpenQueryA( NULL, 0, &query );
295 ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret);
297 ret = PdhCollectQueryData( query );
298 ok(ret == PDH_NO_DATA, "PdhCollectQueryData failed 0x%08x\n", ret);
300 ret = PdhAddCounterA( query, "\\System\\System Up Time", 0, &counter );
301 ok(ret == ERROR_SUCCESS, "PdhAddCounterA failed 0x%08x\n", ret);
303 ret = pPdhCollectQueryDataWithTime( NULL, NULL );
304 ok(ret == PDH_INVALID_ARGUMENT, "PdhCollectQueryDataWithTime failed 0x%08x\n", ret);
306 ret = pPdhCollectQueryDataWithTime( query, NULL );
307 ok(ret == PDH_INVALID_ARGUMENT, "PdhCollectQueryDataWithTime failed 0x%08x\n", ret);
309 ret = pPdhCollectQueryDataWithTime( NULL, &time );
310 ok(ret == PDH_INVALID_HANDLE, "PdhCollectQueryDataWithTime failed 0x%08x\n", ret);
312 ret = pPdhCollectQueryDataWithTime( query, &time );
313 ok(ret == ERROR_SUCCESS, "PdhCollectQueryDataWithTime failed 0x%08x\n", ret);
315 ret = PdhCloseQuery( query );
316 ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret);
319 static void test_PdhGetFormattedCounterValue( void )
323 PDH_HCOUNTER counter;
324 PDH_FMT_COUNTERVALUE value;
326 ret = PdhOpenQueryA( NULL, 0, &query );
327 ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret);
329 ret = PdhAddCounterA( query, "\\System\\System Up Time", 0, &counter );
330 ok(ret == ERROR_SUCCESS, "PdhAddCounterA failed 0x%08x\n", ret);
332 ret = PdhGetFormattedCounterValue( NULL, PDH_FMT_LARGE, NULL, NULL );
333 ok(ret == PDH_INVALID_ARGUMENT, "PdhGetFormattedCounterValue failed 0x%08x\n", ret);
335 ret = PdhGetFormattedCounterValue( NULL, PDH_FMT_LARGE, NULL, &value );
336 ok(ret == PDH_INVALID_HANDLE, "PdhGetFormattedCounterValue failed 0x%08x\n", ret);
338 ret = PdhGetFormattedCounterValue( counter, PDH_FMT_LARGE, NULL, NULL );
339 ok(ret == PDH_INVALID_ARGUMENT, "PdhGetFormattedCounterValue failed 0x%08x\n", ret);
341 ret = PdhGetFormattedCounterValue( counter, PDH_FMT_LARGE, NULL, &value );
342 ok(ret == ERROR_SUCCESS, "PdhGetFormattedCounterValue failed 0x%08x\n", ret);
344 ret = PdhCollectQueryData( query );
345 ok(ret == ERROR_SUCCESS, "PdhCollectQueryData failed 0x%08x\n", ret);
347 ret = PdhGetFormattedCounterValue( counter, PDH_FMT_LARGE, NULL, &value );
348 ok(ret == ERROR_SUCCESS, "PdhGetFormattedCounterValue failed 0x%08x\n", ret);
350 ret = PdhGetFormattedCounterValue( counter, PDH_FMT_LARGE | PDH_FMT_NOSCALE, NULL, &value );
351 ok(ret == ERROR_SUCCESS, "PdhGetFormattedCounterValue failed 0x%08x\n", ret);
353 ret = PdhGetFormattedCounterValue( counter, PDH_FMT_LARGE | PDH_FMT_NOCAP100, NULL, &value );
354 ok(ret == ERROR_SUCCESS, "PdhGetFormattedCounterValue failed 0x%08x\n", ret);
356 ret = PdhGetFormattedCounterValue( counter, PDH_FMT_LARGE | PDH_FMT_1000, NULL, &value );
357 ok(ret == ERROR_SUCCESS, "PdhGetFormattedCounterValue failed 0x%08x\n", ret);
359 ret = PdhSetCounterScaleFactor( counter, 2 );
360 ok(ret == ERROR_SUCCESS, "PdhSetCounterScaleFactor failed 0x%08x\n", ret);
362 ret = PdhGetFormattedCounterValue( counter, PDH_FMT_LARGE, NULL, &value );
363 ok(ret == ERROR_SUCCESS, "PdhGetFormattedCounterValue failed 0x%08x\n", ret);
365 ret = PdhCloseQuery( query );
366 ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret);
369 static void test_PdhGetRawCounterValue( void )
373 PDH_HCOUNTER counter;
374 PDH_RAW_COUNTER value;
376 ret = PdhOpenQueryA( NULL, 0, &query );
377 ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret);
379 ret = PdhAddCounterA( query, "\\System\\System Up Time", 0, &counter );
380 ok(ret == ERROR_SUCCESS, "PdhAddCounterA failed 0x%08x\n", ret);
382 ret = PdhGetRawCounterValue( NULL, NULL, &value );
383 ok(ret == PDH_INVALID_HANDLE, "PdhGetRawCounterValue failed 0x%08x\n", ret);
385 ret = PdhGetRawCounterValue( counter, NULL, NULL );
386 ok(ret == PDH_INVALID_ARGUMENT, "PdhGetRawCounterValue failed 0x%08x\n", ret);
388 ret = PdhGetRawCounterValue( counter, NULL, &value );
389 ok(ret == ERROR_SUCCESS, "PdhGetRawCounterValue failed 0x%08x\n", ret);
390 ok(value.CStatus == ERROR_SUCCESS, "expected ERROR_SUCCESS got %x\n", value.CStatus);
392 ret = PdhCollectQueryData( query );
393 ok(ret == ERROR_SUCCESS, "PdhCollectQueryData failed 0x%08x\n", ret);
395 ret = PdhGetRawCounterValue( counter, NULL, &value );
396 ok(ret == ERROR_SUCCESS, "PdhGetRawCounterValue failed 0x%08x\n", ret);
397 ok(value.CStatus == ERROR_SUCCESS, "expected ERROR_SUCCESS got %x\n", value.CStatus);
399 ret = PdhCloseQuery( query );
400 ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret);
403 static void test_PdhSetCounterScaleFactor( void )
407 PDH_HCOUNTER counter;
409 ret = PdhOpenQueryA( NULL, 0, &query );
410 ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret);
412 ret = PdhAddCounterA( query, "\\System\\System Up Time", 0, &counter );
413 ok(ret == ERROR_SUCCESS, "PdhAddCounterA failed 0x%08x\n", ret);
415 ret = PdhSetCounterScaleFactor( NULL, 8 );
416 ok(ret == PDH_INVALID_HANDLE, "PdhSetCounterScaleFactor failed 0x%08x\n", ret);
418 ret = PdhSetCounterScaleFactor( NULL, 1 );
419 ok(ret == PDH_INVALID_HANDLE, "PdhSetCounterScaleFactor failed 0x%08x\n", ret);
421 ret = PdhSetCounterScaleFactor( counter, 8 );
422 ok(ret == PDH_INVALID_ARGUMENT, "PdhSetCounterScaleFactor failed 0x%08x\n", ret);
424 ret = PdhSetCounterScaleFactor( counter, -8 );
425 ok(ret == PDH_INVALID_ARGUMENT, "PdhSetCounterScaleFactor failed 0x%08x\n", ret);
427 ret = PdhSetCounterScaleFactor( counter, 7 );
428 ok(ret == ERROR_SUCCESS, "PdhSetCounterScaleFactor failed 0x%08x\n", ret);
430 ret = PdhSetCounterScaleFactor( counter, 0 );
431 ok(ret == ERROR_SUCCESS, "PdhSetCounterScaleFactor failed 0x%08x\n", ret);
433 ret = PdhCloseQuery( query );
434 ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret);
437 static void test_PdhGetCounterTimeBase( void )
441 PDH_HCOUNTER counter;
444 ret = PdhOpenQueryA( NULL, 0, &query );
445 ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret);
447 ret = PdhAddCounterA( query, "\\System\\System Up Time", 0, &counter );
448 ok(ret == ERROR_SUCCESS, "PdhAddCounterA failed 0x%08x\n", ret);
450 ret = PdhGetCounterTimeBase( NULL, NULL );
451 ok(ret == PDH_INVALID_ARGUMENT, "PdhGetCounterTimeBase failed 0x%08x\n", ret);
453 ret = PdhGetCounterTimeBase( NULL, &base );
454 ok(ret == PDH_INVALID_HANDLE, "PdhGetCounterTimeBase failed 0x%08x\n", ret);
456 ret = PdhGetCounterTimeBase( counter, NULL );
457 ok(ret == PDH_INVALID_ARGUMENT, "PdhGetCounterTimeBase failed 0x%08x\n", ret);
459 ret = PdhGetCounterTimeBase( counter, &base );
460 ok(ret == ERROR_SUCCESS, "PdhGetCounterTimeBase failed 0x%08x\n", ret);
462 ret = PdhCloseQuery( query );
463 ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret);
466 static void test_PdhGetCounterInfoA( void )
470 PDH_HCOUNTER counter;
471 PDH_COUNTER_INFO_A info;
474 ret = PdhOpenQueryA( NULL, 0, &query );
475 ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret);
477 ret = PdhAddCounterA( query, "\\System\\System Up Time", 0, &counter );
478 ok(ret == ERROR_SUCCESS, "PdhAddCounterA failed 0x%08x\n", ret);
480 ret = PdhGetCounterInfoA( NULL, 0, NULL, NULL );
481 ok(ret == PDH_INVALID_HANDLE || ret == PDH_INVALID_ARGUMENT, "PdhGetCounterInfoA failed 0x%08x\n", ret);
483 ret = PdhGetCounterInfoA( counter, 0, NULL, NULL );
484 ok(ret == PDH_INVALID_ARGUMENT, "PdhGetCounterInfoA failed 0x%08x\n", ret);
486 ret = PdhGetCounterInfoA( counter, 0, NULL, &info );
487 ok(ret == PDH_INVALID_ARGUMENT, "PdhGetCounterInfoA failed 0x%08x\n", ret);
489 size = sizeof(info) - 1;
490 ret = PdhGetCounterInfoA( counter, 0, &size, NULL );
491 ok(ret == PDH_MORE_DATA || ret == PDH_INVALID_ARGUMENT, "PdhGetCounterInfoA failed 0x%08x\n", ret);
494 ret = PdhGetCounterInfoA( counter, 0, &size, &info );
495 ok(ret == ERROR_SUCCESS, "PdhGetCounterInfoA failed 0x%08x\n", ret);
496 ok(size == sizeof(info), "PdhGetCounterInfoA failed %d\n", size);
498 ret = PdhGetCounterInfoA( counter, 0, &size, &info );
499 ok(ret == ERROR_SUCCESS, "PdhGetCounterInfoA failed 0x%08x\n", ret);
500 ok(info.lScale == 0, "lScale %d\n", info.lScale);
502 ret = PdhSetCounterScaleFactor( counter, 0 );
503 ok(ret == ERROR_SUCCESS, "PdhSetCounterScaleFactor failed 0x%08x\n", ret);
505 ret = PdhGetCounterInfoA( counter, 0, &size, &info );
506 ok(ret == ERROR_SUCCESS, "PdhGetCounterInfoA failed 0x%08x\n", ret);
507 ok(info.lScale == 0, "lScale %d\n", info.lScale);
509 ret = PdhSetCounterScaleFactor( counter, -5 );
510 ok(ret == ERROR_SUCCESS, "PdhSetCounterScaleFactor failed 0x%08x\n", ret);
512 ret = PdhGetCounterInfoA( counter, 0, &size, &info );
513 ok(ret == ERROR_SUCCESS, "PdhGetCounterInfoA failed 0x%08x\n", ret);
514 ok(info.lScale == -5, "lScale %d\n", info.lScale);
516 ret = PdhCloseQuery( query );
517 ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret);
520 static void test_PdhGetCounterInfoW( void )
524 PDH_HCOUNTER counter;
525 PDH_COUNTER_INFO_W info;
528 ret = PdhOpenQueryW( NULL, 0, &query );
529 ok(ret == ERROR_SUCCESS, "PdhOpenQueryW failed 0x%08x\n", ret);
531 ret = PdhAddCounterW( query, percentage_processor_time, 0, &counter );
532 ok(ret == ERROR_SUCCESS, "PdhAddCounterW failed 0x%08x\n", ret);
534 ret = PdhGetCounterInfoW( NULL, 0, NULL, NULL );
535 ok(ret == PDH_INVALID_HANDLE || ret == PDH_INVALID_ARGUMENT, "PdhGetCounterInfoW failed 0x%08x\n", ret);
537 ret = PdhGetCounterInfoW( counter, 0, NULL, NULL );
538 ok(ret == PDH_INVALID_ARGUMENT, "PdhGetCounterInfoW failed 0x%08x\n", ret);
540 ret = PdhGetCounterInfoW( counter, 0, NULL, &info );
541 ok(ret == PDH_INVALID_ARGUMENT, "PdhGetCounterInfoW failed 0x%08x\n", ret);
543 size = sizeof(info) - 1;
544 ret = PdhGetCounterInfoW( counter, 0, &size, NULL );
545 ok(ret == PDH_MORE_DATA || ret == PDH_INVALID_ARGUMENT, "PdhGetCounterInfoW failed 0x%08x\n", ret);
548 ret = PdhGetCounterInfoW( counter, 0, &size, &info );
549 ok(ret == ERROR_SUCCESS, "PdhGetCounterInfoW failed 0x%08x\n", ret);
550 ok(size == sizeof(info), "PdhGetCounterInfoW failed %d\n", size);
552 ret = PdhGetCounterInfoW( counter, 0, &size, &info );
553 ok(ret == ERROR_SUCCESS, "PdhGetCounterInfoW failed 0x%08x\n", ret);
554 ok(info.lScale == 0, "lScale %d\n", info.lScale);
556 ret = PdhSetCounterScaleFactor( counter, 0 );
557 ok(ret == ERROR_SUCCESS, "PdhSetCounterScaleFactor failed 0x%08x\n", ret);
559 ret = PdhGetCounterInfoW( counter, 0, &size, &info );
560 ok(ret == ERROR_SUCCESS, "PdhGetCounterInfoW failed 0x%08x\n", ret);
561 ok(info.lScale == 0, "lScale %d\n", info.lScale);
563 ret = PdhSetCounterScaleFactor( counter, -5 );
564 ok(ret == ERROR_SUCCESS, "PdhSetCounterScaleFactor failed 0x%08x\n", ret);
566 ret = PdhGetCounterInfoW( counter, 0, &size, &info );
567 ok(ret == ERROR_SUCCESS, "PdhGetCounterInfoW failed 0x%08x\n", ret);
568 ok(info.lScale == -5, "lScale %d\n", info.lScale);
570 ret = PdhCloseQuery( query );
571 ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret);
574 static void test_PdhLookupPerfIndexByNameA( void )
579 ret = PdhLookupPerfIndexByNameA( NULL, NULL, NULL );
580 ok(ret == PDH_INVALID_ARGUMENT, "PdhLookupPerfIndexByNameA failed 0x%08x\n", ret);
582 ret = PdhLookupPerfIndexByNameA( NULL, NULL, &index );
583 ok(ret == PDH_INVALID_ARGUMENT, "PdhLookupPerfIndexByNameA failed 0x%08x\n", ret);
585 ret = PdhLookupPerfIndexByNameA( NULL, "No Counter", &index );
586 ok(ret == PDH_STRING_NOT_FOUND, "PdhLookupPerfIndexByNameA failed 0x%08x\n", ret);
588 ret = PdhLookupPerfIndexByNameA( NULL, "% Processor Time", NULL );
589 ok(ret == PDH_INVALID_ARGUMENT, "PdhLookupPerfIndexByNameA failed 0x%08x\n", ret);
591 ret = PdhLookupPerfIndexByNameA( NULL, "% Processor Time", &index );
592 ok(ret == ERROR_SUCCESS, "PdhLookupPerfIndexByNameA failed 0x%08x\n", ret);
593 ok(index == 6, "PdhLookupPerfIndexByNameA failed %d\n", index);
595 ret = PdhLookupPerfIndexByNameA( NULL, "System Up Time", &index );
596 ok(ret == ERROR_SUCCESS, "PdhLookupPerfIndexByNameA failed 0x%08x\n", ret);
597 ok(index == 674, "PdhLookupPerfIndexByNameA failed %d\n", index);
600 static void test_PdhLookupPerfIndexByNameW( void )
605 static const WCHAR no_counter[] = {'N','o',' ','C','o','u','n','t','e','r',0};
607 ret = PdhLookupPerfIndexByNameW( NULL, NULL, NULL );
608 ok(ret == PDH_INVALID_ARGUMENT, "PdhLookupPerfIndexByNameW failed 0x%08x\n", ret);
610 ret = PdhLookupPerfIndexByNameW( NULL, NULL, &index );
611 ok(ret == PDH_INVALID_ARGUMENT, "PdhLookupPerfIndexByNameW failed 0x%08x\n", ret);
613 ret = PdhLookupPerfIndexByNameW( NULL, no_counter, &index );
614 ok(ret == PDH_STRING_NOT_FOUND, "PdhLookupPerfIndexByNameW failed 0x%08x\n", ret);
616 ret = PdhLookupPerfIndexByNameW( NULL, processor_time, NULL );
617 ok(ret == PDH_INVALID_ARGUMENT, "PdhLookupPerfIndexByNameW failed 0x%08x\n", ret);
619 ret = PdhLookupPerfIndexByNameW( NULL, processor_time, &index );
620 ok(ret == ERROR_SUCCESS, "PdhLookupPerfIndexByNameW failed 0x%08x\n", ret);
621 ok(index == 6, "PdhLookupPerfIndexByNameW failed %d\n", index);
623 ret = PdhLookupPerfIndexByNameW( NULL, uptime, &index );
624 ok(ret == ERROR_SUCCESS, "PdhLookupPerfIndexByNameW failed 0x%08x\n", ret);
625 ok(index == 674, "PdhLookupPerfIndexByNameW failed %d\n", index);
628 static void test_PdhLookupPerfNameByIndexA( void )
631 char buffer[PDH_MAX_COUNTER_NAME] = "!!";
634 ret = PdhLookupPerfNameByIndexA( NULL, 0, NULL, NULL );
635 ok(ret == PDH_INVALID_ARGUMENT, "PdhLookupPerfNameByIndexA failed 0x%08x\n", ret);
638 ret = PdhLookupPerfNameByIndexA( NULL, 6, buffer, &size );
639 ok(ret == PDH_MORE_DATA || ret == PDH_INSUFFICIENT_BUFFER, "PdhLookupPerfNameByIndexA failed 0x%08x\n", ret);
641 size = sizeof(buffer);
642 ret = PdhLookupPerfNameByIndexA( NULL, 6, buffer, &size );
643 ok(ret == ERROR_SUCCESS, "PdhLookupPerfNameByIndexA failed 0x%08x\n", ret);
644 ok(!lstrcmpA( buffer, "% Processor Time" ),
645 "PdhLookupPerfNameByIndexA failed, got %s expected \'%% Processor Time\'\n", buffer);
646 ok(size == sizeof("% Processor Time"), "PdhLookupPerfNameByIndexA failed %d\n", size);
648 size = sizeof(buffer);
649 ret = PdhLookupPerfNameByIndexA( NULL, 674, NULL, &size );
650 ok(ret == PDH_INVALID_ARGUMENT ||
651 ret == PDH_MORE_DATA, /* win2k3 */
652 "PdhLookupPerfNameByIndexA failed 0x%08x\n", ret);
654 size = sizeof(buffer);
655 ret = PdhLookupPerfNameByIndexA( NULL, 674, buffer, &size );
656 ok(ret == ERROR_SUCCESS, "PdhLookupPerfNameByIndexA failed 0x%08x\n", ret);
657 ok(!lstrcmpA( buffer, "System Up Time" ),
658 "PdhLookupPerfNameByIndexA failed, got %s expected \'System Up Time\'\n", buffer);
659 ok(size == sizeof("System Up Time"), "PdhLookupPerfNameByIndexA failed %d\n", size);
662 static void test_PdhLookupPerfNameByIndexW( void )
665 WCHAR buffer[PDH_MAX_COUNTER_NAME];
668 ret = PdhLookupPerfNameByIndexW( NULL, 0, NULL, NULL );
669 ok(ret == PDH_INVALID_ARGUMENT, "PdhLookupPerfNameByIndexW failed 0x%08x\n", ret);
672 ret = PdhLookupPerfNameByIndexW( NULL, 6, buffer, &size );
673 ok(ret == PDH_MORE_DATA || ret == PDH_INSUFFICIENT_BUFFER, "PdhLookupPerfNameByIndexW failed 0x%08x\n", ret);
675 size = sizeof(buffer) / sizeof(WCHAR);
676 ret = PdhLookupPerfNameByIndexW( NULL, 6, buffer, &size );
677 ok(ret == ERROR_SUCCESS, "PdhLookupPerfNameByIndexW failed 0x%08x\n", ret);
678 ok(size == sizeof(processor_time) / sizeof(WCHAR), "PdhLookupPerfNameByIndexW failed %d\n", size);
680 size = sizeof(buffer) / sizeof(WCHAR);
681 ret = PdhLookupPerfNameByIndexW( NULL, 674, NULL, &size );
682 ok(ret == PDH_INVALID_ARGUMENT ||
683 ret == PDH_MORE_DATA, /* win2k3 */
684 "PdhLookupPerfNameByIndexW failed 0x%08x\n", ret);
686 size = sizeof(buffer) / sizeof(WCHAR);
687 ret = PdhLookupPerfNameByIndexW( NULL, 674, buffer, &size );
688 ok(ret == ERROR_SUCCESS, "PdhLookupPerfNameByIndexW failed 0x%08x\n", ret);
689 ok(size == sizeof(uptime) / sizeof(WCHAR), "PdhLookupPerfNameByIndexW failed %d\n", size);
692 static void test_PdhValidatePathA( void )
696 ret = PdhValidatePathA( NULL );
697 ok(ret == PDH_INVALID_ARGUMENT, "PdhValidatePathA failed 0x%08x\n", ret);
699 ret = PdhValidatePathA( "" );
700 ok(ret == PDH_INVALID_ARGUMENT, "PdhValidatePathA failed 0x%08x\n", ret);
702 ret = PdhValidatePathA( "\\System" );
703 ok(ret == PDH_CSTATUS_BAD_COUNTERNAME, "PdhValidatePathA failed 0x%08x\n", ret);
705 ret = PdhValidatePathA( "System Up Time" );
706 ok(ret == PDH_CSTATUS_BAD_COUNTERNAME, "PdhValidatePathA failed 0x%08x\n", ret);
708 ret = PdhValidatePathA( "\\System\\System Down Time" );
709 ok(ret == PDH_CSTATUS_NO_COUNTER, "PdhValidatePathA failed 0x%08x\n", ret);
711 ret = PdhValidatePathA( "\\System\\System Up Time" );
712 ok(ret == ERROR_SUCCESS, "PdhValidatePathA failed 0x%08x\n", ret);
715 static void test_PdhValidatePathW( void )
719 static const WCHAR empty[] = {0};
720 static const WCHAR system[] = {'\\','S','y','s','t','e','m',0};
722 ret = PdhValidatePathW( NULL );
723 ok(ret == PDH_INVALID_ARGUMENT, "PdhValidatePathW failed 0x%08x\n", ret);
725 ret = PdhValidatePathW( empty );
726 ok(ret == PDH_INVALID_ARGUMENT, "PdhValidatePathW failed 0x%08x\n", ret);
728 ret = PdhValidatePathW( system );
729 ok(ret == PDH_CSTATUS_BAD_COUNTERNAME, "PdhValidatePathW failed 0x%08x\n", ret);
731 ret = PdhValidatePathW( uptime );
732 ok(ret == PDH_CSTATUS_BAD_COUNTERNAME, "PdhValidatePathW failed 0x%08x\n", ret);
734 ret = PdhValidatePathW( system_downtime );
735 ok(ret == PDH_CSTATUS_NO_COUNTER, "PdhValidatePathW failed 0x%08x\n", ret);
737 ret = PdhValidatePathW( system_uptime );
738 ok(ret == ERROR_SUCCESS, "PdhValidatePathW failed 0x%08x\n", ret);
741 static void test_PdhValidatePathExA( void )
745 ret = pPdhValidatePathExA( NULL, NULL );
746 ok(ret == PDH_INVALID_ARGUMENT, "PdhValidatePathExA failed 0x%08x\n", ret);
748 ret = pPdhValidatePathExA( NULL, "" );
749 ok(ret == PDH_INVALID_ARGUMENT, "PdhValidatePathExA failed 0x%08x\n", ret);
751 ret = pPdhValidatePathExA( NULL, "\\System" );
752 ok(ret == PDH_CSTATUS_BAD_COUNTERNAME, "PdhValidatePathExA failed 0x%08x\n", ret);
754 ret = pPdhValidatePathExA( NULL, "System Up Time" );
755 ok(ret == PDH_CSTATUS_BAD_COUNTERNAME, "PdhValidatePathExA failed 0x%08x\n", ret);
757 ret = pPdhValidatePathExA( NULL, "\\System\\System Down Time" );
758 ok(ret == PDH_CSTATUS_NO_COUNTER, "PdhValidatePathExA failed 0x%08x\n", ret);
760 ret = pPdhValidatePathExA( NULL, "\\System\\System Up Time" );
761 ok(ret == ERROR_SUCCESS, "PdhValidatePathExA failed 0x%08x\n", ret);
764 static void test_PdhValidatePathExW( void )
768 static const WCHAR empty[] = {0};
769 static const WCHAR system[] = {'\\','S','y','s','t','e','m',0};
771 ret = pPdhValidatePathExW( NULL, NULL );
772 ok(ret == PDH_INVALID_ARGUMENT, "PdhValidatePathExW failed 0x%08x\n", ret);
774 ret = pPdhValidatePathExW( NULL, empty );
775 ok(ret == PDH_INVALID_ARGUMENT, "PdhValidatePathExW failed 0x%08x\n", ret);
777 ret = pPdhValidatePathExW( NULL, system );
778 ok(ret == PDH_CSTATUS_BAD_COUNTERNAME, "PdhValidatePathExW failed 0x%08x\n", ret);
780 ret = pPdhValidatePathExW( NULL, uptime );
781 ok(ret == PDH_CSTATUS_BAD_COUNTERNAME, "PdhValidatePathExW failed 0x%08x\n", ret);
783 ret = pPdhValidatePathExW( NULL, system_downtime );
784 ok(ret == PDH_CSTATUS_NO_COUNTER, "PdhValidatePathExW failed 0x%08x\n", ret);
786 ret = pPdhValidatePathExW( NULL, system_uptime );
787 ok(ret == ERROR_SUCCESS, "PdhValidatePathExW failed 0x%08x\n", ret);
790 static void test_PdhCollectQueryDataEx(void)
794 PDH_HCOUNTER counter;
799 status = PdhOpenQueryA( NULL, 0, &query );
800 ok(status == ERROR_SUCCESS, "PdhOpenQuery failed 0x%08x\n", status);
802 event = CreateEventA( NULL, FALSE, FALSE, "winetest" );
803 ok(event != NULL, "CreateEvent failed\n");
805 status = PdhAddCounterA( query, "\\System\\System Up Time", 0, &counter );
806 ok(status == ERROR_SUCCESS, "PdhAddCounterA failed 0x%08x\n", status);
808 status = PdhCollectQueryDataEx( NULL, 1, event );
809 ok(status == PDH_INVALID_HANDLE, "PdhCollectQueryDataEx failed 0x%08x\n", status);
811 status = PdhCollectQueryDataEx( query, 1, NULL );
812 ok(status == ERROR_SUCCESS, "PdhCollectQueryDataEx failed 0x%08x\n", status);
814 status = PdhCollectQueryDataEx( query, 1, event );
815 ok(status == ERROR_SUCCESS, "PdhCollectQueryDataEx failed 0x%08x\n", status);
817 status = PdhCollectQueryData( query );
818 ok(status == ERROR_SUCCESS, "PdhCollectQueryData failed 0x%08x\n", status);
820 for (i = 0; i < 3; i++)
822 if (WaitForSingleObject( event, INFINITE ) == WAIT_OBJECT_0)
824 PDH_FMT_COUNTERVALUE value;
826 status = PdhGetFormattedCounterValue( counter, PDH_FMT_LARGE, NULL, &value );
827 ok(status == ERROR_SUCCESS, "PdhGetFormattedCounterValue failed 0x%08x\n", status);
829 trace( "uptime %x%08x\n", (DWORD)(U(value).largeValue >> 32), (DWORD)U(value).largeValue );
833 ret = CloseHandle( event );
834 ok(ret, "CloseHandle failed\n");
836 status = PdhCloseQuery( query );
837 ok(status == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", status);
840 static void test_PdhMakeCounterPathA(void)
843 PDH_COUNTER_PATH_ELEMENTS_A e;
847 ret = PdhMakeCounterPathA(NULL, NULL, NULL, 0);
848 ok(ret == PDH_INVALID_ARGUMENT, "PdhMakeCounterPathA failed 0x%08x\n", ret);
851 ret = PdhMakeCounterPathA(NULL, NULL, &buflen, 0);
852 ok(ret == PDH_INVALID_ARGUMENT, "PdhMakeCounterPathA failed 0x%08x\n", ret);
855 ret = PdhMakeCounterPathA(NULL, buffer, &buflen, 0);
856 ok(ret == PDH_INVALID_ARGUMENT, "PdhMakeCounterPathA failed 0x%08x\n", ret);
858 buflen = sizeof(buffer);
859 memset(&e, 0, sizeof(e));
860 ret = PdhMakeCounterPathA(&e, buffer, &buflen, 0);
861 ok(ret == PDH_INVALID_ARGUMENT, "PdhMakeCounterPathA failed 0x%08x\n", ret);
864 buflen = sizeof(buffer);
865 e.szMachineName = (char *)"machine";
866 ret = PdhMakeCounterPathA(&e, buffer, &buflen, 0);
867 ok(ret == PDH_INVALID_ARGUMENT, "PdhMakeCounterPathA failed 0x%08x\n", ret);
868 ok(!strcmp(buffer, ""), "expected \"machine\" got %s\n", buffer);
871 buflen = sizeof(buffer);
872 e.szObjectName = (char *)"object";
873 ret = PdhMakeCounterPathA(&e, buffer, &buflen, 0);
874 ok(ret == PDH_INVALID_ARGUMENT, "PdhMakeCounterPathA failed 0x%08x\n", ret);
875 ok(!strcmp(buffer, ""), "expected \"machine\" got %s\n", buffer);
878 buflen = sizeof(buffer);
879 e.szInstanceName = (char *)"instance";
880 ret = PdhMakeCounterPathA(&e, buffer, &buflen, 0);
881 ok(ret == PDH_INVALID_ARGUMENT, "PdhMakeCounterPathA failed 0x%08x\n", ret);
882 ok(!strcmp(buffer, ""), "expected \"machine\" got %s\n", buffer);
885 buflen = sizeof(buffer);
886 e.szParentInstance = (char *)"parent";
887 ret = PdhMakeCounterPathA(&e, buffer, &buflen, 0);
888 ok(ret == PDH_INVALID_ARGUMENT, "PdhMakeCounterPathA failed 0x%08x\n", ret);
889 ok(!strcmp(buffer, ""), "expected \"machine\" got %s\n", buffer);
892 buflen = sizeof(buffer);
893 e.dwInstanceIndex = 1;
894 ret = PdhMakeCounterPathA(&e, buffer, &buflen, 0);
895 ok(ret == PDH_INVALID_ARGUMENT, "PdhMakeCounterPathA failed 0x%08x\n", ret);
896 ok(!strcmp(buffer, ""), "expected \"machine\" got %s\n", buffer);
899 buflen = sizeof(buffer);
900 e.szCounterName = (char *)"counter";
901 ret = PdhMakeCounterPathA(&e, buffer, &buflen, 0);
902 ok(ret == ERROR_SUCCESS, "PdhMakeCounterPathA failed 0x%08x\n", ret);
903 ok(!strcmp(buffer, "\\\\machine\\object(parent/instance#1)\\counter"),
904 "expected \"\\\\machine\\object(parent/instance#1)\\counter\" got %s\n", buffer);
907 buflen = sizeof(buffer);
908 e.szParentInstance = NULL;
909 ret = PdhMakeCounterPathA(&e, buffer, &buflen, 0);
910 ok(ret == ERROR_SUCCESS, "PdhMakeCounterPathA failed 0x%08x\n", ret);
911 ok(!strcmp(buffer, "\\\\machine\\object(instance#1)\\counter"),
912 "expected \"\\\\machine\\object(instance#1)\\counter\" got %s\n", buffer);
915 buflen = sizeof(buffer);
916 e.szInstanceName = NULL;
917 ret = PdhMakeCounterPathA(&e, buffer, &buflen, 0);
918 ok(ret == ERROR_SUCCESS, "PdhMakeCounterPathA failed 0x%08x\n", ret);
919 ok(!strcmp(buffer, "\\\\machine\\object\\counter"),
920 "expected \"\\\\machine\\object\\counter\" got %s\n", buffer);
923 buflen = sizeof(buffer);
924 e.szMachineName = NULL;
925 ret = PdhMakeCounterPathA(&e, buffer, &buflen, 0);
926 ok(ret == ERROR_SUCCESS, "PdhMakeCounterPathA failed 0x%08x\n", ret);
927 ok(!strcmp(buffer, "\\object\\counter"),
928 "expected \"\\object\\counter\" got %s\n", buffer);
931 buflen = sizeof(buffer);
932 e.szObjectName = NULL;
933 ret = PdhMakeCounterPathA(&e, buffer, &buflen, 0);
934 ok(ret == PDH_INVALID_ARGUMENT, "PdhMakeCounterPathA failed 0x%08x\n", ret);
937 static void test_PdhGetDllVersion(void)
942 ret = PdhGetDllVersion(NULL);
943 ok(ret == PDH_INVALID_ARGUMENT ||
944 broken(ret == ERROR_SUCCESS), /* Vista+ */
945 "Expected PdhGetDllVersion to return PDH_INVALID_ARGUMENT, got %d\n", ret);
947 ret = PdhGetDllVersion(&version);
948 ok(ret == ERROR_SUCCESS,
949 "Expected PdhGetDllVersion to return ERROR_SUCCESS, got %d\n", ret);
951 if (ret == ERROR_SUCCESS)
953 ok(version == PDH_CVERSION_WIN50 ||
954 version == PDH_VERSION,
955 "Expected version number to be PDH_CVERSION_WIN50 or PDH_VERSION, got %u\n", version);
961 if (PRIMARYLANGID(LANGIDFROMLCID(GetThreadLocale())) != LANG_ENGLISH)
963 skip("non-english locale\n");
966 init_function_ptrs();
968 test_PdhOpenQueryA();
969 test_PdhOpenQueryW();
971 test_PdhAddCounterA();
972 test_PdhAddCounterW();
974 if (pPdhAddEnglishCounterA) test_PdhAddEnglishCounterA();
975 if (pPdhAddEnglishCounterW) test_PdhAddEnglishCounterW();
976 if (pPdhCollectQueryDataWithTime) test_PdhCollectQueryDataWithTime();
978 test_PdhGetFormattedCounterValue();
979 test_PdhGetRawCounterValue();
980 test_PdhSetCounterScaleFactor();
981 test_PdhGetCounterTimeBase();
983 test_PdhGetCounterInfoA();
984 test_PdhGetCounterInfoW();
986 test_PdhLookupPerfIndexByNameA();
987 test_PdhLookupPerfIndexByNameW();
989 test_PdhLookupPerfNameByIndexA();
990 test_PdhLookupPerfNameByIndexW();
992 test_PdhValidatePathA();
993 test_PdhValidatePathW();
995 if (pPdhValidatePathExA) test_PdhValidatePathExA();
996 if (pPdhValidatePathExW) test_PdhValidatePathExW();
998 test_PdhCollectQueryDataEx();
999 test_PdhMakeCounterPathA();
1000 test_PdhGetDllVersion();