Mariusz Pluciński : gameux: Add partial implementation of IGameStatisticsMgr::GetGameStatistics.

Alexandre Julliard julliard at winehq.org
Fri Sep 24 11:43:44 CDT 2010


Module: wine
Branch: master
Commit: 23efe79289a019fec68708425e66baf3baee84ba
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=23efe79289a019fec68708425e66baf3baee84ba

Author: Mariusz Pluciński <vshader at gmail.com>
Date:   Thu Sep 23 15:37:42 2010 +0200

gameux: Add partial implementation of IGameStatisticsMgr::GetGameStatistics.

---

 dlls/gameux/gameexplorer.c   |   39 +++----------------------------
 dlls/gameux/gamestatistics.c |   52 ++++++++++++++++++++++++++++++++++++++++-
 dlls/gameux/gameux_private.h |   49 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 103 insertions(+), 37 deletions(-)

diff --git a/dlls/gameux/gameexplorer.c b/dlls/gameux/gameexplorer.c
index 1816ebd..744ae8a 100644
--- a/dlls/gameux/gameexplorer.c
+++ b/dlls/gameux/gameexplorer.c
@@ -69,29 +69,9 @@ void GAMEUX_uninitGameData(struct GAMEUX_GAME_DATA *GameData)
 /*******************************************************************************
  * GAMEUX_buildGameRegistryPath
  *
- * Helper function, builds registry path to key, where game's data are stored
- *
- * Parameters:
- *  installScope                [I]     the scope which was used in AddGame/InstallGame call
- *  gameInstanceId              [I]     game instance GUID. If NULL, then only
- *                                      path to scope will be returned
- *  lpRegistryPath              [O]     pointer which will receive address to string
- *                                      containing expected registry path. Path
- *                                      is relative to HKLM registry key. It
- *                                      must be freed by calling HeapFree(GetProcessHeap(), 0, ...)
- *
- * Name of game's registry key always follows patterns below:
- *  When game is installed for current user only (installScope is GIS_CURRENT_USER):
- *      HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\
- *          GameUX\[user's security ID]\[game instance ID]
- *
- *  When game is installed for all users (installScope is GIS_ALL_USERS):
- *      HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\
- *          GameUX\Games\[game instance ID]
- *
- *
+ * Internal helper function. Description available in gameux_private.h file
  */
-static HRESULT GAMEUX_buildGameRegistryPath(GAME_INSTALL_SCOPE installScope,
+HRESULT GAMEUX_buildGameRegistryPath(GAME_INSTALL_SCOPE installScope,
         LPCGUID gameInstanceId,
         LPWSTR* lpRegistryPath)
 {
@@ -697,20 +677,9 @@ static HRESULT GAMEUX_UpdateGame(LPGUID InstanceID) {
 /*******************************************************************************
  * GAMEUX_FindGameInstanceId
  *
- * Helper funtion. Searches for instance identifier of given game in given
- * installation scope.
- *
- * Parameters:
- *  sGDFBinaryPath                          [I]     path to binary containing GDF
- *  installScope                            [I]     game install scope to search in
- *  pInstanceId                             [O]     instance identifier of given game
- *
- * Returns:
- *  S_OK                    id was returned properly
- *  S_FALSE                 id was not found in the registry
- *  E_OUTOFMEMORY           problem while memory allocation
+ * Internal helper function. Description available in gameux_private.h file
  */
-static HRESULT GAMEUX_FindGameInstanceId(
+HRESULT GAMEUX_FindGameInstanceId(
         LPCWSTR sGDFBinaryPath,
         GAME_INSTALL_SCOPE installScope,
         GUID* pInstanceId)
diff --git a/dlls/gameux/gamestatistics.c b/dlls/gameux/gamestatistics.c
index 098754e..0b872ac 100644
--- a/dlls/gameux/gamestatistics.c
+++ b/dlls/gameux/gamestatistics.c
@@ -22,6 +22,7 @@
 #include "config.h"
 
 #include "ole2.h"
+#include "winreg.h"
 
 #include "gameux.h"
 #include "gameux_private.h"
@@ -107,8 +108,55 @@ static HRESULT STDMETHODCALLTYPE GameStatisticsMgrImpl_GetGameStatistics(
         GAMESTATS_OPEN_RESULT *pOpenResult,
         IGameStatistics **ppiStats)
 {
-    FIXME("stub (%p, %s, 0x%x, %p, %p)\n", iface, debugstr_w(GDFBinaryPath), openType, pOpenResult, ppiStats);
-    return E_NOTIMPL;
+    static const WCHAR sApplicationId[] =
+            {'A','p','p','l','i','c','a','t','i','o','n','I','d',0};
+
+    HRESULT hr;
+    GUID instanceId;
+    LPWSTR lpRegistryPath = NULL;
+    WCHAR lpApplicationId[49];
+    DWORD dwLength = sizeof(lpApplicationId);
+    GAME_INSTALL_SCOPE installScope;
+
+    TRACE("(%p, %s, 0x%x, %p, %p)\n", iface, debugstr_w(GDFBinaryPath), openType, pOpenResult, ppiStats);
+
+    if(!GDFBinaryPath)
+        return E_INVALIDARG;
+
+    installScope = GIS_CURRENT_USER;
+    hr = GAMEUX_FindGameInstanceId(GDFBinaryPath, installScope, &instanceId);
+
+    if(hr == S_FALSE)
+    {
+        installScope = GIS_ALL_USERS;
+        hr = GAMEUX_FindGameInstanceId(GDFBinaryPath, installScope, &instanceId);
+    }
+
+    if(hr == S_FALSE)
+        /* game not registered, so statistics cannot be used */
+        hr = E_FAIL;
+
+    if(SUCCEEDED(hr))
+        /* game is registered, let's read it's application id from registry */
+        hr = GAMEUX_buildGameRegistryPath(installScope, &instanceId, &lpRegistryPath);
+
+    if(SUCCEEDED(hr))
+    {
+        hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE,
+                lpRegistryPath, sApplicationId, RRF_RT_REG_SZ,
+                NULL, lpApplicationId, &dwLength));
+    }
+
+    if(SUCCEEDED(hr))
+    {
+        TRACE("found app id: %s\n", debugstr_w(lpApplicationId));
+        FIXME("creating instance of IGameStatistics not yet implemented\n");
+        hr = E_NOTIMPL;
+    }
+
+    HeapFree(GetProcessHeap(), 0, lpRegistryPath);
+
+    return hr;
 }
 
 static HRESULT STDMETHODCALLTYPE GameStatisticsMgrImpl_RemoveGameStatistics(
diff --git a/dlls/gameux/gameux_private.h b/dlls/gameux/gameux_private.h
index 97826f0..86532e2 100644
--- a/dlls/gameux/gameux_private.h
+++ b/dlls/gameux/gameux_private.h
@@ -86,3 +86,52 @@ HRESULT WINAPI GAMEUX_RegisterGame(LPCWSTR sGDFBinaryPath,
         LPCWSTR sGameInstallDirectory,
         GAME_INSTALL_SCOPE installScope,
         GUID *pInstanceID);
+/*******************************************************************************
+ * GAMEUX_FindGameInstanceId
+ *
+ * Helper funtion. Searches for instance identifier of given game in given
+ * installation scope. Implemented in gameexplorer.c
+ *
+ * Parameters:
+ *  sGDFBinaryPath                          [I]     path to binary containing GDF
+ *  installScope                            [I]     game install scope to search in
+ *  pInstanceId                             [O]     instance identifier of given game
+ *
+ * Returns:
+ *  S_OK                    id was returned properly
+ *  S_FALSE                 id was not found in the registry
+ *  E_OUTOFMEMORY           problem while memory allocation
+ */
+HRESULT GAMEUX_FindGameInstanceId(
+        LPCWSTR sGDFBinaryPath,
+        GAME_INSTALL_SCOPE installScope,
+        GUID* pInstanceId);
+/*******************************************************************************
+ * GAMEUX_buildGameRegistryPath
+ *
+ * Helper function, builds registry path to key, where game's data are stored.
+ * Implemented in gameexplorer.c
+ *
+ * Parameters:
+ *  installScope                [I]     the scope which was used in AddGame/InstallGame call
+ *  gameInstanceId              [I]     game instance GUID. If NULL, then only
+ *                                      path to scope will be returned
+ *  lpRegistryPath              [O]     pointer which will receive address to string
+ *                                      containing expected registry path. Path
+ *                                      is relative to HKLM registry key. It
+ *                                      must be freed by calling HeapFree(GetProcessHeap(), 0, ...)
+ *
+ * Name of game's registry key always follows patterns below:
+ *  When game is installed for current user only (installScope is GIS_CURRENT_USER):
+ *      HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\
+ *          GameUX\[user's security ID]\[game instance ID]
+ *
+ *  When game is installed for all users (installScope is GIS_ALL_USERS):
+ *      HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\
+ *          GameUX\Games\[game instance ID]
+ *
+ *
+ */
+HRESULT GAMEUX_buildGameRegistryPath(GAME_INSTALL_SCOPE installScope,
+        LPCGUID gameInstanceId,
+        LPWSTR* lpRegistryPath);




More information about the wine-cvs mailing list