OLD | NEW |
| (Empty) |
1 // Copyright 2011 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 // | |
16 // Author: grt | |
17 // | |
18 // A dummy app installer that does nothing more than write error information to | |
19 // the registry as per the Google Update Installer Result API and return 1. | |
20 | |
21 #include <windows.h> | |
22 | |
23 #define GOOGLE_UPDATE_KEY L"SOFTWARE\\Google\\Update" | |
24 #define TEST_SETUP_APP_GUID L"{665BDD8E-F40C-4384-A9C6-CA3CD5665C83}" | |
25 | |
26 namespace { | |
27 | |
28 const DWORD kInstallerResultFailedCustomError = 1; | |
29 const wchar_t kErrorString[] = L"This is a detailed error message."; | |
30 const wchar_t kRegClientStateKey[] = | |
31 GOOGLE_UPDATE_KEY L"\\ClientState\\" TEST_SETUP_APP_GUID; | |
32 const wchar_t kRegInstallerResultValue[] = L"InstallerResult"; | |
33 const wchar_t kRegInstallerResultUIStringValue[] = L"InstallerResultUIString"; | |
34 | |
35 void WriteFailureValues() { | |
36 HKEY client_state_key; | |
37 LONG result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, kRegClientStateKey, 0, NULL, | |
38 REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, | |
39 &client_state_key, NULL); | |
40 if (result == ERROR_SUCCESS) { | |
41 RegSetValueEx( | |
42 client_state_key, kRegInstallerResultValue, 0, REG_DWORD, | |
43 reinterpret_cast<const BYTE*>(&kInstallerResultFailedCustomError), | |
44 sizeof(kInstallerResultFailedCustomError)); | |
45 RegSetValueEx( | |
46 client_state_key, kRegInstallerResultUIStringValue, 0, REG_SZ, | |
47 reinterpret_cast<const BYTE*>(&kErrorString), | |
48 sizeof(kErrorString)); | |
49 RegCloseKey(client_state_key); | |
50 } | |
51 } | |
52 | |
53 } // namespace | |
54 | |
55 int wmain(int argc, wchar_t* argv[]) { | |
56 WriteFailureValues(); | |
57 return 1; | |
58 } | |
OLD | NEW |