static HRESULT WINAPI GameExplorer2Impl_InstallGame( IGameExplorer2 *iface, LPCWSTR binaryGDFPath, LPCWSTR installDirectory, GAME_INSTALL_SCOPE installScope) { HRESULT hr; GUID instanceId; GameExplorerImpl *This = impl_from_IGameExplorer2(iface); TRACE("(%p, %s, %s, 0x%x)\n", This, debugstr_w(binaryGDFPath), debugstr_w(installDirectory), installScope); if(!binaryGDFPath) return E_INVALIDARG; hr = GAMEUX_FindGameInstanceId(binaryGDFPath, GIS_CURRENT_USER, &instanceId); if(hr == S_FALSE) hr = GAMEUX_FindGameInstanceId(binaryGDFPath, GIS_ALL_USERS, &instanceId); if(hr == S_FALSE) { /* if game isn't yet registered, then install it */ instanceId = GUID_NULL; hr = GAMEUX_RegisterGame(binaryGDFPath, installDirectory, installScope, &instanceId); } else if(hr == S_OK) /* otherwise, update game */ hr = GAMEUX_UpdateGame(&instanceId); return hr; }
/******************************************************************************* * GAMEUX_UpdateGame * * Helper function, updates stored data about game with given InstanceID */ static HRESULT GAMEUX_UpdateGame(LPGUID InstanceID) { static const WCHAR sConfigGDFBinaryPath[] = {'C','o','n','f','i','g','G','D','F','B','i','n','a','r','y','P','a','t','h',0}; static const WCHAR sConfigApplicationPath[] = {'C','o','n','f','i','g','A','p','p','l','i','c','a','t','i','o','n','P','a','t','h',0}; HRESULT hr; GAME_INSTALL_SCOPE installScope; LPWSTR lpRegistryPath; LPWSTR lpGDFBinaryPath; TRACE("(%s)\n", debugstr_guid(InstanceID)); /* first, check is game exists in CURRENT_USER scope */ installScope = GIS_CURRENT_USER; hr = GAMEUX_IsGameKeyExist(installScope, InstanceID, &lpRegistryPath); if(hr == S_FALSE) { /* game not found in CURRENT_USER scope, let's check in ALL_USERS */ installScope = GIS_ALL_USERS; hr = GAMEUX_IsGameKeyExist(installScope, InstanceID, &lpRegistryPath); } if(hr == S_FALSE) /* still not found? let's inform user that game does not exists */ hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); if(SUCCEEDED(hr)) { WCHAR *lpGameInstallDirectory = NULL; /* game found, its registry path is in lpRegistryPath and install * scope in installScope */ TRACE("game found in registry (path %s), updating\n", debugstr_w(lpRegistryPath)); /* first, read required data about game */ hr = GAMEUX_LoadRegistryString(HKEY_LOCAL_MACHINE, lpRegistryPath, sConfigGDFBinaryPath, &lpGDFBinaryPath); if(SUCCEEDED(hr)) hr = GAMEUX_LoadRegistryString(HKEY_LOCAL_MACHINE, lpRegistryPath, sConfigApplicationPath, &lpGameInstallDirectory); /* now remove currently existing registry key */ if(SUCCEEDED(hr)) hr = GAMEUX_RemoveRegistryRecord(InstanceID); /* and add it again, it will cause in reparsing of whole GDF */ if(SUCCEEDED(hr)) hr = GAMEUX_RegisterGame(lpGDFBinaryPath, lpGameInstallDirectory, installScope, InstanceID); HeapFree(GetProcessHeap(), 0, lpGDFBinaryPath); HeapFree(GetProcessHeap(), 0, lpGameInstallDirectory); } HeapFree(GetProcessHeap(), 0, lpRegistryPath); TRACE("returning 0x%x\n", hr); return hr; }
static HRESULT WINAPI GameExplorerImpl_AddGame( IGameExplorer *iface, BSTR bstrGDFBinaryPath, BSTR sGameInstallDirectory, GAME_INSTALL_SCOPE installScope, GUID *pInstanceID) { GameExplorerImpl *This = impl_from_IGameExplorer(iface); TRACE("(%p, %s, %s, 0x%x, %s)\n", This, debugstr_w(bstrGDFBinaryPath), debugstr_w(sGameInstallDirectory), installScope, debugstr_guid(pInstanceID)); return GAMEUX_RegisterGame(bstrGDFBinaryPath, sGameInstallDirectory, installScope, pInstanceID); }