include/msvcrt: Define more CPU control word flags.
[wine] / dlls / gameux / tests / gamestatistics.c
1 /*
2  * IGameStatisticsMgr tests
3  *
4  * Copyright (C) 2010 Mariusz PluciƄski
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #define COBJMACROS
22
23 #include "shlwapi.h"
24 #include "oleauto.h"
25 #include "shlobj.h"
26
27 #include "gameux.h"
28 #include "wine/test.h"
29
30 /*******************************************************************************
31  * utilities
32  */
33 static IGameExplorer *ge = NULL;
34 static WCHAR sExeName[MAX_PATH] = {0};
35 static GUID gameInstanceId;
36 static HRESULT WINAPI (*pSHGetFolderPathW)(HWND,int,HANDLE,DWORD,LPWSTR);
37 /*******************************************************************************
38  *_loadDynamicRoutines
39  *
40  * Helper function, prepares pointers to system procedures which may be not
41  * available on older operating systems.
42  *
43  * Returns:
44  *  TRUE                        procedures were loaded successfully
45  *  FALSE                       procedures were not loaded successfully
46  */
47 static BOOL _loadDynamicRoutines(void)
48 {
49     HMODULE hModule = LoadLibraryA( "shell32.dll" );
50
51     pSHGetFolderPathW = (LPVOID)GetProcAddress(hModule, "SHGetFolderPathW");
52     if (!pSHGetFolderPathW) return FALSE;
53     return TRUE;
54 }
55 /*******************************************************************************
56  * _registerGame
57  * Registers test suite executable as game in Games Explorer. Required to test
58  * game statistics.
59  */
60 static HRESULT _registerGame(void) {
61     HRESULT hr;
62     WCHAR sExePath[MAX_PATH];
63     BSTR bstrExeName, bstrExePath;
64     DWORD dwExeNameLen;
65
66     /* prepare path to binary */
67     dwExeNameLen = GetModuleFileNameW(NULL, sExeName, sizeof (sExeName) / sizeof (sExeName[0]));
68     hr = (dwExeNameLen!= 0 ? S_OK : E_FAIL);
69     lstrcpynW(sExePath, sExeName, StrRChrW(sExeName, NULL, '\\') - sExeName + 1);
70
71     bstrExeName = SysAllocString(sExeName);
72     if(!bstrExeName) hr = E_OUTOFMEMORY;
73
74     bstrExePath = SysAllocString(sExePath);
75     if(!bstrExePath) hr = E_OUTOFMEMORY;
76
77     if(SUCCEEDED(hr))
78     {
79         gameInstanceId = GUID_NULL;
80         hr = CoCreateInstance(&CLSID_GameExplorer, NULL, CLSCTX_INPROC_SERVER,
81                               &IID_IGameExplorer, (LPVOID*)&ge);
82     }
83
84     if(SUCCEEDED(hr))
85         hr = IGameExplorer_AddGame(ge, bstrExeName, bstrExePath,
86                                    GIS_CURRENT_USER, &gameInstanceId);
87
88     if(FAILED(hr) && ge)
89     {
90         IGameExplorer_Release(ge);
91         ge = NULL;
92     }
93
94     SysFreeString(bstrExeName);
95     SysFreeString(bstrExePath);
96     return hr;
97 }
98 /*******************************************************************************
99  * _unregisterGame
100  * Unregisters test suite from Games Explorer.
101  */
102 static HRESULT _unregisterGame(void) {
103     HRESULT hr;
104
105     if(!ge) return E_FAIL;
106
107     hr = IGameExplorer_RemoveGame(ge, gameInstanceId);
108
109     IGameExplorer_Release(ge);
110     ge = NULL;
111
112     return hr;
113 }
114 /*******************************************************************************
115  * _buildStatisticsFilePath
116  * Creates path to file contaning statistics of game with given id.
117  *
118  * Parameters:
119  *  guidApplicationId                       [I]     application id of game
120  *  lpStatisticsFile                        [O]     pointer where address of
121  *                                                  string with path will be
122  *                                                  stored. Path must be deallocated
123  *                                                  using CoTaskMemFree(...)
124  */
125 static HRESULT _buildStatisticsFilePath(LPCGUID guidApplicationId, LPWSTR *lpStatisticsFile)
126 {
127     static const WCHAR sBackslash[] = {'\\',0};
128     static const WCHAR sStatisticsDir[] = {'\\','M','i','c','r','o','s','o','f','t',
129             '\\','W','i','n','d','o','w','s','\\','G','a','m','e','E','x','p',
130             'l','o','r','e','r','\\','G','a','m','e','S','t','a','t','i','s',
131             't','i','c','s',0};
132     static const WCHAR sDotGamestats[] = {'.','g','a','m','e','s','t','a','t','s',0};
133     static const DWORD dwGuidLength = 49;
134
135     HRESULT hr;
136     WCHAR sGuid[dwGuidLength], sPath[MAX_PATH] = {0};
137
138     hr = pSHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, sPath);
139
140     if(SUCCEEDED(hr))
141         hr = (StringFromGUID2(guidApplicationId, sGuid, dwGuidLength)!=0 ? S_OK : E_FAIL);
142
143     if(SUCCEEDED(hr))
144     {
145         lstrcatW(sPath, sStatisticsDir);
146         lstrcatW(sPath, sGuid);
147         lstrcatW(sPath, sBackslash);
148         lstrcatW(sPath, sGuid);
149         lstrcatW(sPath, sDotGamestats);
150
151         *lpStatisticsFile = CoTaskMemAlloc((lstrlenW(sPath)+1)*sizeof(WCHAR));
152         if(!*lpStatisticsFile) hr = E_OUTOFMEMORY;
153     }
154
155     if(SUCCEEDED(hr))
156         lstrcpyW(*lpStatisticsFile, sPath);
157
158     return hr;
159 }
160 /*******************************************************************************
161  * _isFileExist
162  * Checks if given file exists
163  *
164  * Parameters:
165  *  lpFile                          [I]     path to file
166  *
167  * Result:
168  *  TRUE        file exists
169  *  FALSE       file does not exist
170  */
171 static BOOL _isFileExists(LPCWSTR lpFile)
172 {
173     HANDLE hFile = CreateFileW(lpFile, GENERIC_READ, 0, NULL,
174                                OPEN_EXISTING, 0, NULL);
175     if(hFile == INVALID_HANDLE_VALUE) return FALSE;
176     CloseHandle(hFile);
177     return TRUE;
178 }
179 /*******************************************************************************
180  * test routines
181  */
182 static void test_create(BOOL* gameStatisticsAvailable)
183 {
184     HRESULT hr;
185
186     IGameStatisticsMgr* gsm = NULL;
187     *gameStatisticsAvailable = FALSE;
188
189     /* interface available up from Win7 */
190     hr = CoCreateInstance( &CLSID_GameStatistics, NULL, CLSCTX_INPROC_SERVER, &IID_IGameStatisticsMgr, (LPVOID*)&gsm);
191     if(gsm)
192     {
193         ok( hr == S_OK, "IGameStatisticsMgr creating failed (result: 0x%08x)\n", hr);
194         *gameStatisticsAvailable = TRUE;
195         IGameStatisticsMgr_Release(gsm);
196     }
197     else
198         win_skip("IGameStatisticsMgr cannot be created\n");
199 }
200 static void test_gamestatisticsmgr( void )
201 {
202     static const GUID guidApplicationId = { 0x17A6558E, 0x60BE, 0x4078, { 0xB6, 0x6F, 0x9C, 0x3A, 0xDA, 0x2A, 0x32, 0xE6 } };
203     static const WCHAR sCategory0[] = {'C','a','t','e','g','o','r','y','0',0};
204     static const WCHAR sCategory1[] = {'C','a','t','e','g','o','r','y','1',0};
205     static const WCHAR sCategory2[] = {'C','a','t','e','g','o','r','y','2',0};
206     static const WCHAR sCategory0a[] = {'C','a','t','e','g','o','r','y','0','a',0};
207     static const WCHAR sStatistic00[] = {'S','t','a','t','i','s','t','i','c','0','0',0};
208     static const WCHAR sStatistic01[] = {'S','t','a','t','i','s','t','i','c','0','1',0};
209     static const WCHAR sStatistic10[] = {'S','t','a','t','i','s','t','i','c','1','0',0};
210     static const WCHAR sStatistic11[] = {'S','t','a','t','i','s','t','i','c','1','1',0};
211     static const WCHAR sStatistic20[] = {'S','t','a','t','i','s','t','i','c','2','0',0};
212     static const WCHAR sStatistic21[] = {'S','t','a','t','i','s','t','i','c','2','1',0};
213     static const WCHAR sValue00[] = {'V','a','l','u','e','0','0',0};
214     static const WCHAR sValue01[] = {'V','a','l','u','e','0','1',0};
215     static const WCHAR sValue10[] = {'V','a','l','u','e','1','0',0};
216     static const WCHAR sValue11[] = {'V','a','l','u','e','1','1',0};
217     static const WCHAR sValue20[] = {'V','a','l','u','e','2','0',0};
218     static const WCHAR sValue21[] = {'V','a','l','u','e','2','1',0};
219
220     HRESULT hr;
221     DWORD dwOpenResult;
222     LPWSTR lpStatisticsFile = NULL;
223     LPWSTR lpName = NULL, lpValue = NULL, sTooLongString = NULL;
224     UINT uMaxCategoryLength = 0, uMaxNameLength = 0, uMaxValueLength = 0;
225     WORD wMaxStatsPerCategory = 0, wMaxCategories = 0;
226
227     IGameStatisticsMgr* gsm = NULL;
228     IGameStatistics* gs = NULL;
229
230     hr = CoCreateInstance( &CLSID_GameStatistics, NULL, CLSCTX_INPROC_SERVER, &IID_IGameStatisticsMgr, (LPVOID*)&gsm);
231     ok(hr == S_OK, "IGameStatisticsMgr creating failed (result false)\n");
232
233     /* test trying to create interface IGameStatistics using GetGameStatistics method */
234
235     /* this should fail, cause statistics doesn't yet exists */
236     hr = IGameStatisticsMgr_GetGameStatistics(gsm, sExeName, GAMESTATS_OPEN_OPENONLY, &dwOpenResult, &gs);
237     ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "GetGameStatistics returned unexpected value: 0x%08x\n", hr);
238
239     /* now, allow to create */
240     hr = IGameStatisticsMgr_GetGameStatistics(gsm, sExeName, GAMESTATS_OPEN_OPENORCREATE, &dwOpenResult, &gs);
241     ok(SUCCEEDED(hr), "GetGameStatistics returned error: 0x%x\n", hr);
242     ok(gs!=NULL, "GetGameStatistics did not return valid interface pointer\n");
243     if(gs)
244     {
245         /* test of limit values returned from interface */
246         hr = IGameStatistics_GetMaxCategoryLength(gs, &uMaxCategoryLength);
247         ok(hr==S_OK, "getting maximum length of category failed\n");
248         ok(uMaxCategoryLength==60, "getting maximum length of category returned invalid value: %d\n", uMaxCategoryLength);
249
250         hr = IGameStatistics_GetMaxNameLength(gs, &uMaxNameLength);
251         ok(hr==S_OK, "getting maximum name length failed\n");
252         ok(uMaxNameLength==30, "getting maximum name length returned invalid value: %d\n", uMaxNameLength);
253
254         hr = IGameStatistics_GetMaxValueLength(gs, &uMaxValueLength);
255         ok(hr==S_OK, "getting maximum value length failed\n");
256         ok(uMaxValueLength==30, "getting maximum value length returned invalid value: %d\n", uMaxValueLength);
257
258         hr = IGameStatistics_GetMaxCategories(gs, &wMaxCategories);
259         ok(hr==S_OK, "getting maximum number of categories failed\n");
260         ok(wMaxCategories==10, "getting maximum number of categories returned invalid value: %d\n", wMaxCategories);
261
262         hr = IGameStatistics_GetMaxStatsPerCategory(gs, &wMaxStatsPerCategory);
263         ok(hr==S_OK, "getting maximum number of statistics per category failed\n");
264         ok(wMaxStatsPerCategory==10, "getting maximum number of statistics per category returned invalid value: %d\n", wMaxStatsPerCategory);
265
266         /* create name of statistics file */
267         hr = _buildStatisticsFilePath(&guidApplicationId, &lpStatisticsFile);
268         ok(SUCCEEDED(hr), "cannot build path to game statistics (error 0x%x)\n", hr);
269         trace("statistics file path: %s\n", wine_dbgstr_w(lpStatisticsFile));
270         ok(_isFileExists(lpStatisticsFile) == FALSE, "statistics file %s already exists\n", wine_dbgstr_w(lpStatisticsFile));
271
272         /* write sample statistics */
273         hr = IGameStatistics_SetCategoryTitle(gs, wMaxCategories, NULL);
274         ok(hr==E_INVALIDARG, "setting category title invalid value: 0x%x\n", hr);
275
276         hr = IGameStatistics_SetCategoryTitle(gs, wMaxCategories, sCategory0);
277         ok(hr==E_INVALIDARG, "setting category title invalid value: 0x%x\n", hr);
278
279         /* check what happen if string is too long */
280         sTooLongString = CoTaskMemAlloc(sizeof(WCHAR)*(uMaxCategoryLength+2));
281         memset(sTooLongString, 'a', sizeof(WCHAR)*(uMaxCategoryLength+1));
282         sTooLongString[uMaxCategoryLength+1]=0;
283
284         /* when string is too long, Windows returns S_FALSE, but saves string (stripped to expected number of characters) */
285         hr = IGameStatistics_SetCategoryTitle(gs, 0, sTooLongString);
286         ok(hr==S_FALSE, "setting category title invalid result: 0x%x\n", hr);
287         CoTaskMemFree(sTooLongString);
288
289         ok(IGameStatistics_SetCategoryTitle(gs, 0, sCategory0)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory0));
290         ok(IGameStatistics_SetCategoryTitle(gs, 1, sCategory1)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory1));
291         ok(IGameStatistics_SetCategoryTitle(gs, 2, sCategory2)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory1));
292
293         /* check what happen if any string is NULL */
294         hr = IGameStatistics_SetStatistic(gs, 0, 0, NULL, sValue00);
295         ok(hr == S_FALSE, "setting statistic returned unexpected value: 0x%x)\n", hr);
296
297         hr = IGameStatistics_SetStatistic(gs, 0, 0, sStatistic00, NULL);
298         ok(hr == S_OK, "setting statistic returned unexpected value: 0x%x)\n", hr);
299
300         /* check what happen if any string is too long */
301         sTooLongString = CoTaskMemAlloc(sizeof(WCHAR)*(uMaxNameLength+2));
302         memset(sTooLongString, 'a', sizeof(WCHAR)*(uMaxNameLength+1));
303         sTooLongString[uMaxNameLength+1]=0;
304         hr = IGameStatistics_SetStatistic(gs, 0, 0, sTooLongString, sValue00);
305         ok(hr == S_FALSE, "setting statistic returned unexpected value: 0x%x)\n", hr);
306         CoTaskMemFree(sTooLongString);
307
308         sTooLongString = CoTaskMemAlloc(sizeof(WCHAR)*(uMaxValueLength+2));
309         memset(sTooLongString, 'a', sizeof(WCHAR)*(uMaxValueLength+1));
310         sTooLongString[uMaxValueLength+1]=0;
311         hr = IGameStatistics_SetStatistic(gs, 0, 0, sStatistic00, sTooLongString);
312         ok(hr == S_FALSE, "setting statistic returned unexpected value: 0x%x)\n", hr);
313         CoTaskMemFree(sTooLongString);
314
315         /* check what happen on too big index of category or statistic */
316         hr = IGameStatistics_SetStatistic(gs, wMaxCategories, 0, sStatistic00, sValue00);
317         ok(hr == E_INVALIDARG, "setting statistic returned unexpected value: 0x%x)\n", hr);
318
319         hr = IGameStatistics_SetStatistic(gs, 0, wMaxStatsPerCategory, sStatistic00, sValue00);
320         ok(hr == E_INVALIDARG, "setting statistic returned unexpected value: 0x%x)\n", hr);
321
322         ok(IGameStatistics_SetStatistic(gs, 0, 0, sStatistic00, sValue00)==S_OK, "setting statistic failed: name=%s, value=%s\n", wine_dbgstr_w(sStatistic00), wine_dbgstr_w(sValue00));
323         ok(IGameStatistics_SetStatistic(gs, 0, 1, sStatistic01, sValue01)==S_OK, "setting statistic failed: name=%s, value=%s\n", wine_dbgstr_w(sStatistic01), wine_dbgstr_w(sValue01));
324         ok(IGameStatistics_SetStatistic(gs, 1, 0, sStatistic10, sValue10)==S_OK, "setting statistic failed: name=%s, value=%s\n", wine_dbgstr_w(sStatistic10), wine_dbgstr_w(sValue10));
325         ok(IGameStatistics_SetStatistic(gs, 1, 1, sStatistic11, sValue11)==S_OK, "setting statistic failed: name=%s, value=%s\n", wine_dbgstr_w(sStatistic11), wine_dbgstr_w(sValue11));
326         ok(IGameStatistics_SetStatistic(gs, 2, 0, sStatistic20, sValue20)==S_OK, "setting statistic failed: name=%s, value=%s\n", wine_dbgstr_w(sStatistic20), wine_dbgstr_w(sValue20));
327         ok(IGameStatistics_SetStatistic(gs, 2, 1, sStatistic21, sValue21)==S_OK, "setting statistic failed: name=%s, value=%s\n", wine_dbgstr_w(sStatistic21), wine_dbgstr_w(sValue21));
328
329         ok(_isFileExists(lpStatisticsFile) == FALSE, "statistics file %s already exists\n", wine_dbgstr_w(lpStatisticsFile));
330
331         ok(IGameStatistics_Save(gs, FALSE)==S_OK, "statistic saving failed\n");
332
333         ok(_isFileExists(lpStatisticsFile) == TRUE, "statistics file %s does not exists\n", wine_dbgstr_w(lpStatisticsFile));
334
335         /* this value should not be stored in storage, we need it only to test is it not saved */
336         ok(IGameStatistics_SetCategoryTitle(gs, 0, sCategory0a)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory0a));
337
338         hr = IGameStatistics_Release(gs);
339         ok(SUCCEEDED(hr), "releasing IGameStatistics returned error: 0x%08x\n", hr);
340
341         /* try to read written statisticd */
342         hr = IGameStatisticsMgr_GetGameStatistics(gsm, sExeName, GAMESTATS_OPEN_OPENORCREATE, &dwOpenResult, &gs);
343         ok(SUCCEEDED(hr), "GetGameStatistics returned error: 0x%08x\n", hr);
344         ok(dwOpenResult == GAMESTATS_OPEN_OPENED, "GetGameStatistics returned invalid open result: 0x%x\n", dwOpenResult);
345         ok(gs!=NULL, "GetGameStatistics did not return valid interface pointer\n");
346
347         /* verify values with these which we stored before*/
348         hr = IGameStatistics_GetCategoryTitle(gs, 0, &lpName);
349         ok(hr == S_OK, "getting category title failed\n");
350         ok(lstrcmpW(lpName, sCategory0)==0, "getting category title returned invalid string (%s)\n", wine_dbgstr_w(lpName));
351         CoTaskMemFree(lpName);
352
353         hr = IGameStatistics_GetCategoryTitle(gs, 1, &lpName);
354         ok(hr == S_OK, "getting category title failed\n");
355         ok(lstrcmpW(lpName, sCategory1)==0, "getting category title returned invalid string (%s)\n", wine_dbgstr_w(lpName));
356         CoTaskMemFree(lpName);
357
358         hr = IGameStatistics_GetCategoryTitle(gs, 2, &lpName);
359         ok(hr == S_OK, "getting category title failed\n");
360         ok(lstrcmpW(lpName, sCategory2)==0, "getting category title returned invalid string (%s)\n", wine_dbgstr_w(lpName));
361         CoTaskMemFree(lpName);
362
363         /* check result if category doesn't exists */
364         hr = IGameStatistics_GetCategoryTitle(gs, 3, &lpName);
365         ok(hr == S_OK, "getting category title failed\n");
366         ok(lpName == NULL, "getting category title failed\n");
367         CoTaskMemFree(lpName);
368
369         hr = IGameStatistics_GetStatistic(gs, 0, 0, &lpName, &lpValue);
370         ok(hr == S_OK, "getting statistic failed\n");
371         ok(lstrcmpW(lpName, sStatistic00)==0, "getting statistic returned invalid name\n");
372         ok(lstrcmpW(lpValue, sValue00)==0, "getting statistic returned invalid value\n");
373         CoTaskMemFree(lpName);
374         CoTaskMemFree(lpValue);
375
376         hr = IGameStatistics_GetStatistic(gs, 0, 1, &lpName, &lpValue);
377         ok(hr == S_OK, "getting statistic failed\n");
378         ok(lstrcmpW(lpName, sStatistic01)==0, "getting statistic returned invalid name\n");
379         ok(lstrcmpW(lpValue, sValue01)==0, "getting statistic returned invalid value\n");
380         CoTaskMemFree(lpName);
381         CoTaskMemFree(lpValue);
382
383         hr = IGameStatistics_GetStatistic(gs, 1, 0, &lpName, &lpValue);
384         ok(hr == S_OK, "getting statistic failed\n");
385         ok(lstrcmpW(lpName, sStatistic10)==0, "getting statistic returned invalid name\n");
386         ok(lstrcmpW(lpValue, sValue10)==0, "getting statistic returned invalid value\n");
387         CoTaskMemFree(lpName);
388         CoTaskMemFree(lpValue);
389
390         hr = IGameStatistics_GetStatistic(gs, 1, 1, &lpName, &lpValue);
391         ok(hr == S_OK, "getting statistic failed\n");
392         ok(lstrcmpW(lpName, sStatistic11)==0, "getting statistic returned invalid name\n");
393         ok(lstrcmpW(lpValue, sValue11)==0, "getting statistic returned invalid value\n");
394         CoTaskMemFree(lpName);
395         CoTaskMemFree(lpValue);
396
397         hr = IGameStatistics_GetStatistic(gs, 2, 0, &lpName, &lpValue);
398         ok(hr == S_OK, "getting statistic failed\n");
399         ok(lstrcmpW(lpName, sStatistic20)==0, "getting statistic returned invalid name\n");
400         ok(lstrcmpW(lpValue, sValue20)==0, "getting statistic returned invalid value\n");
401         CoTaskMemFree(lpName);
402         CoTaskMemFree(lpValue);
403
404         hr = IGameStatistics_GetStatistic(gs, 2, 1, &lpName, &lpValue);
405         ok(hr == S_OK, "getting statistic failed\n");
406         ok(lstrcmpW(lpName, sStatistic21)==0, "getting statistic returned invalid name\n");
407         ok(lstrcmpW(lpValue, sValue21)==0, "getting statistic returned invalid value\n");
408         CoTaskMemFree(lpName);
409         CoTaskMemFree(lpValue);
410
411         hr = IGameStatistics_Release(gs);
412         ok(SUCCEEDED(hr), "releasing IGameStatistics returned error: 0x%x\n", hr);
413
414         /* test of removing game statistics from underlying storage */
415         ok(_isFileExists(lpStatisticsFile) == TRUE, "statistics file %s does not exists\n", wine_dbgstr_w(lpStatisticsFile));
416         hr = IGameStatisticsMgr_RemoveGameStatistics(gsm, sExeName);
417         ok(SUCCEEDED(hr), "cannot remove game statistics, error: 0x%x\n", hr);
418         ok(_isFileExists(lpStatisticsFile) == FALSE, "statistics file %s still exists\n", wine_dbgstr_w(lpStatisticsFile));
419     }
420
421     hr = IGameStatisticsMgr_Release(gsm);
422     ok(SUCCEEDED(hr), "releasing IGameStatisticsMgr returned error: 0x%x\n", hr);
423
424     CoTaskMemFree(lpStatisticsFile);
425 }
426
427 START_TEST(gamestatistics)
428 {
429     HRESULT hr;
430     BOOL gameStatisticsAvailable;
431
432     if(_loadDynamicRoutines())
433     {
434         hr = CoInitialize( NULL );
435         ok( hr == S_OK, "failed to init COM\n");
436
437         test_create(&gameStatisticsAvailable);
438
439         if(gameStatisticsAvailable)
440         {
441             hr = _registerGame();
442             ok( hr == S_OK, "cannot register game in Game Explorer (error: 0x%x)\n", hr);
443
444             test_gamestatisticsmgr();
445
446             hr = _unregisterGame();
447             ok( hr == S_OK, "cannot unregister game from Game Explorer (error: 0x%x)\n", hr);
448         }
449
450         CoUninitialize();
451     }
452     else
453         /* this is not a failure, because a procedure loaded by address
454          * is always available on systems which has gameux.dll */
455         win_skip("too old system, cannot load required dynamic procedures\n");
456 }