OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef DEVICE_CORE_DEVICE_INFO_QUERY_WIN_H_ |
| 6 #define DEVICE_CORE_DEVICE_INFO_QUERY_WIN_H_ |
| 7 |
| 8 #include <windows.h> |
| 9 #include <setupapi.h> |
| 10 |
| 11 #include <string> |
| 12 |
| 13 #include "base/macros.h" |
| 14 #include "device/core/device_core_export.h" |
| 15 |
| 16 namespace device { |
| 17 |
| 18 // Wraps HDEVINFO and SP_DEVINFO_DATA into a class that can automatically |
| 19 // release them. Provides interfaces that can add a device using its |
| 20 // device path, get device info and get device string property. |
| 21 class DEVICE_CORE_EXPORT DeviceInfoQueryWin { |
| 22 public: |
| 23 DeviceInfoQueryWin(); |
| 24 ~DeviceInfoQueryWin(); |
| 25 |
| 26 // Add a device to |device_info_list_| using its |device_path| so that |
| 27 // its device info can be retrieved. |
| 28 bool AddDevice(const char* device_path); |
| 29 // Get the device info and store it into |device_info_data_|, this function |
| 30 // should be called at most once. |
| 31 bool GetDeviceInfo(); |
| 32 // Get device string property and store it into |property_buffer|. |
| 33 bool GetDeviceStringProperty(DWORD property, std::string* property_buffer); |
| 34 |
| 35 bool device_info_list_valid() { |
| 36 return device_info_list_ != INVALID_HANDLE_VALUE; |
| 37 } |
| 38 |
| 39 private: |
| 40 HDEVINFO device_info_list_ = INVALID_HANDLE_VALUE; |
| 41 // When device_info_data_.cbSize != 0, |device_info_data_| is valid. |
| 42 SP_DEVINFO_DATA device_info_data_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(DeviceInfoQueryWin); |
| 45 }; |
| 46 |
| 47 } // namespace device |
| 48 |
| 49 #endif // DEVICE_CORE_DEVICE_INFO_QUERY_WIN_H_ |
OLD | NEW |