local_device_info_util_win.cc 721 B

1234567891011121314151617181920212223242526
  1. // Copyright (c) 2012 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. #include <windows.h>
  5. #include <string>
  6. #include "base/check.h"
  7. #include "base/strings/utf_string_conversions.h"
  8. namespace syncer {
  9. std::string GetPersonalizableDeviceNameInternal() {
  10. wchar_t computer_name[MAX_COMPUTERNAME_LENGTH + 1] = {0};
  11. DWORD size = std::size(computer_name);
  12. if (::GetComputerNameW(computer_name, &size)) {
  13. std::string result;
  14. bool conversion_successful = base::WideToUTF8(computer_name, size, &result);
  15. DCHECK(conversion_successful);
  16. return result;
  17. }
  18. return std::string();
  19. }
  20. } // namespace syncer