OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/installer/util/wmi.h" | 5 #include "chrome/installer/util/wmi.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/win/scoped_bstr.h" | 10 #include "base/win/scoped_bstr.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 hr = out_params->Get(L"ProcessId", 0, &pid, NULL, 0); | 128 hr = out_params->Get(L"ProcessId", 0, &pid, NULL, 0); |
129 if (FAILED(hr) || 0 == V_I4(&pid)) | 129 if (FAILED(hr) || 0 == V_I4(&pid)) |
130 return false; | 130 return false; |
131 | 131 |
132 if (process_id) | 132 if (process_id) |
133 *process_id = V_I4(&pid); | 133 *process_id = V_I4(&pid); |
134 | 134 |
135 return true; | 135 return true; |
136 } | 136 } |
137 | 137 |
138 string16 WMIComputerSystem::GetModel() { | 138 base::string16 WMIComputerSystem::GetModel() { |
139 base::win::ScopedComPtr<IWbemServices> services; | 139 base::win::ScopedComPtr<IWbemServices> services; |
140 if (!WMI::CreateLocalConnection(true, services.Receive())) | 140 if (!WMI::CreateLocalConnection(true, services.Receive())) |
141 return string16(); | 141 return base::string16(); |
142 | 142 |
143 base::win::ScopedBstr query_language(L"WQL"); | 143 base::win::ScopedBstr query_language(L"WQL"); |
144 base::win::ScopedBstr query(L"SELECT * FROM Win32_ComputerSystem"); | 144 base::win::ScopedBstr query(L"SELECT * FROM Win32_ComputerSystem"); |
145 base::win::ScopedComPtr<IEnumWbemClassObject> enumerator; | 145 base::win::ScopedComPtr<IEnumWbemClassObject> enumerator; |
146 HRESULT hr = services->ExecQuery( | 146 HRESULT hr = services->ExecQuery( |
147 query_language, query, | 147 query_language, query, |
148 WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, | 148 WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, |
149 enumerator.Receive()); | 149 enumerator.Receive()); |
150 if (FAILED(hr) || !enumerator) | 150 if (FAILED(hr) || !enumerator) |
151 return string16(); | 151 return base::string16(); |
152 | 152 |
153 base::win::ScopedComPtr<IWbemClassObject> class_object; | 153 base::win::ScopedComPtr<IWbemClassObject> class_object; |
154 ULONG items_returned = 0; | 154 ULONG items_returned = 0; |
155 hr = enumerator->Next(WBEM_INFINITE, 1, class_object.Receive(), | 155 hr = enumerator->Next(WBEM_INFINITE, 1, class_object.Receive(), |
156 &items_returned); | 156 &items_returned); |
157 if (!items_returned) | 157 if (!items_returned) |
158 return string16(); | 158 return base::string16(); |
159 | 159 |
160 base::win::ScopedVariant manufacturer; | 160 base::win::ScopedVariant manufacturer; |
161 class_object->Get(L"Manufacturer", 0, manufacturer.Receive(), 0, 0); | 161 class_object->Get(L"Manufacturer", 0, manufacturer.Receive(), 0, 0); |
162 base::win::ScopedVariant model; | 162 base::win::ScopedVariant model; |
163 class_object->Get(L"Model", 0, model.Receive(), 0, 0); | 163 class_object->Get(L"Model", 0, model.Receive(), 0, 0); |
164 | 164 |
165 string16 model_string; | 165 base::string16 model_string; |
166 if (manufacturer.type() == VT_BSTR) { | 166 if (manufacturer.type() == VT_BSTR) { |
167 model_string = V_BSTR(&manufacturer); | 167 model_string = V_BSTR(&manufacturer); |
168 if (model.type() == VT_BSTR) | 168 if (model.type() == VT_BSTR) |
169 model_string += L" "; | 169 model_string += L" "; |
170 } | 170 } |
171 if (model.type() == VT_BSTR) | 171 if (model.type() == VT_BSTR) |
172 model_string += V_BSTR(&model); | 172 model_string += V_BSTR(&model); |
173 | 173 |
174 return model_string; | 174 return model_string; |
175 } | 175 } |
176 | 176 |
177 } // namespace installer | 177 } // namespace installer |
OLD | NEW |