Home | History | Annotate | Download | only in win
      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.
      4 
      5 #include "ui/base/win/lock_state.h"
      6 
      7 #include <windows.h>
      8 
      9 namespace ui {
     10 
     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;
     20     }
     21     ::CloseDesktop(input_desk);
     22   }
     23   return is_locked;
     24 }
     25 
     26 }  // namespace ui
     27