| OLD | NEW |
| (Empty) |
| 1 // Copyright 2006-2009 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 #ifndef OMAHA_COMMON_WMI_QUERY_H_ | |
| 17 #define OMAHA_COMMON_WMI_QUERY_H_ | |
| 18 | |
| 19 #include <windows.h> | |
| 20 #include <wbemidl.h> | |
| 21 #include <atlbase.h> | |
| 22 #include <atlcomcli.h> | |
| 23 #include <atlstr.h> | |
| 24 #include "base/basictypes.h" | |
| 25 | |
| 26 namespace omaha { | |
| 27 | |
| 28 class WmiQuery { | |
| 29 public: | |
| 30 WmiQuery(); | |
| 31 ~WmiQuery(); | |
| 32 | |
| 33 // Connects to the server to get WMI service. | |
| 34 HRESULT Connect(const TCHAR* resource); | |
| 35 | |
| 36 // Queries the service. | |
| 37 HRESULT Query(const TCHAR* query); | |
| 38 | |
| 39 // Reads the next row. | |
| 40 HRESULT Next(); | |
| 41 | |
| 42 // Returns true at the end. | |
| 43 bool AtEnd(); | |
| 44 | |
| 45 // Gets the value of the named property. | |
| 46 HRESULT GetValue(const TCHAR* name, CComVariant* value); | |
| 47 HRESULT GetValue(const TCHAR* name, CString* value); | |
| 48 HRESULT GetValue(const TCHAR* name, bool* value); | |
| 49 HRESULT GetValue(const TCHAR* name, int* value); | |
| 50 HRESULT GetValue(const TCHAR* name, uint32* value); | |
| 51 | |
| 52 private: | |
| 53 CComPtr<IWbemLocator> wbem_; | |
| 54 CComPtr<IWbemServices> service_; | |
| 55 CComPtr<IEnumWbemClassObject> enumerator_; | |
| 56 CComPtr<IWbemClassObject> obj_; | |
| 57 bool at_end_; | |
| 58 | |
| 59 DISALLOW_EVIL_CONSTRUCTORS(WmiQuery); | |
| 60 }; | |
| 61 | |
| 62 } // namespace omaha | |
| 63 | |
| 64 #endif // OMAHA_COMMON_WMI_QUERY_H_ | |
| 65 | |
| OLD | NEW |