OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "cloud_print/service/win/service_utils.h" | 5 #include "cloud_print/service/win/service_utils.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <security.h> // NOLINT | 8 #include <security.h> // NOLINT |
9 | 9 |
10 string16 GetCurrentUserName() { | 10 string16 GetCurrentUserName() { |
11 ULONG size = 0; | 11 ULONG size = 0; |
12 string16 result; | 12 string16 result; |
13 ::GetUserNameEx(::NameSamCompatible, NULL, &size); | 13 ::GetUserNameEx(::NameSamCompatible, NULL, &size); |
14 result.resize(size); | 14 result.resize(size); |
15 if (result.empty()) | 15 if (result.empty()) |
16 return result; | 16 return result; |
17 if (!::GetUserNameEx(::NameSamCompatible, &result[0], &size)) | 17 if (!::GetUserNameEx(::NameSamCompatible, &result[0], &size)) |
18 result.clear(); | 18 result.clear(); |
19 result.resize(size); | 19 result.resize(size); |
20 return result; | 20 return result; |
21 } | 21 } |
22 | 22 |
23 | 23 |
OLD | NEW |