cros: Fix EasyUnlockServiceSignin::OnUserDataLoaded crash.
[chromium-blink-merge.git] / ui / base / win / lock_state.cc
blobc56eae429fc8804660cbd68e0af4371c8f67fe5f
1 // Copyright 2014 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.
5 #include "ui/base/win/lock_state.h"
7 #include <windows.h>
9 namespace ui {
11 bool IsWorkstationLocked() {
12 bool is_locked = true;
13 HDESK input_desk = ::OpenInputDesktop(0, 0, GENERIC_READ);
14 if (input_desk) {
15 wchar_t name[256] = {0};
16 DWORD needed = 0;
17 if (::GetUserObjectInformation(
18 input_desk, UOI_NAME, name, sizeof(name), &needed)) {
19 is_locked = lstrcmpi(name, L"default") != 0;
21 ::CloseDesktop(input_desk);
23 return is_locked;
26 } // namespace ui