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 #include "omaha/base/firewall_product_detection.h" | |
17 #include "omaha/base/debug.h" | |
18 #include "omaha/base/logging.h" | |
19 #include "omaha/base/reg_key.h" | |
20 #include "omaha/base/utils.h" | |
21 #include "omaha/base/wmi_query.h" | |
22 | |
23 namespace omaha { | |
24 | |
25 namespace firewall_detection { | |
26 | |
27 namespace { | |
28 | |
29 const TCHAR kWmiSecurityCenter[] = _T("root\\SecurityCenter"); | |
30 const TCHAR kWmiQueryFirewallProduct[] = _T("select * from FirewallProduct"); | |
31 const TCHAR kWmiPropDisplayName[] = _T("displayName"); | |
32 const TCHAR kWmiPropVersionNumber[] = _T("versionNumber"); | |
33 | |
34 } // namespace | |
35 | |
36 | |
37 HRESULT Detect(CString* name, CString* version) { | |
38 ASSERT1(name); | |
39 ASSERT1(version); | |
40 | |
41 name->Empty(); | |
42 version->Empty(); | |
43 | |
44 WmiQuery wmi_query; | |
45 HRESULT hr = wmi_query.Connect(kWmiSecurityCenter); | |
46 if (FAILED(hr)) { | |
47 return hr; | |
48 } | |
49 hr = wmi_query.Query(kWmiQueryFirewallProduct); | |
50 if (FAILED(hr)) { | |
51 return hr; | |
52 } | |
53 if (wmi_query.AtEnd()) { | |
54 return E_FAIL; | |
55 } | |
56 hr = wmi_query.GetValue(kWmiPropDisplayName, name); | |
57 if (FAILED(hr)) { | |
58 return hr; | |
59 } | |
60 wmi_query.GetValue(kWmiPropVersionNumber, version); | |
61 return S_OK; | |
62 } | |
63 | |
64 } // namespace firewall_detection | |
65 | |
66 } // namespace omaha | |
67 | |
OLD | NEW |