locked
[UWP]How can we get unlock the windows 10 device automatically after locking? RRS feed

  • Question

  • hI 

    I am developing the UWP app where I need to lock the system and automatically unlock the system on WNS PUSH receive.

    I am only able to lock the system but not able to unlock automatically, its getting unlock when we press any key or move mouse.

    Is there any way to do the same? Can we do it through console app? (we can call console through Desktop Bridge feature).

    OR

    Same apply for sleep mode. we can sleep but we cant wake up. any way to do the same through UWP or through console app ?


    sandeep chauhan



    Tuesday, November 27, 2018 2:54 PM

All replies

  • Hi,

    >> I am only able to lock the system but not able to unlock automatically

    Do you want to unlock the windows system or your own UWP project? And how do you lock it?

    If it is the first one, I’m afraid you can not unlock it with C# code.

    In general, the user needs to enter a password to unlock the system, this is an user action and each user has a different password, so how do you want to unlock the system?

    Regards, 

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 28, 2018 9:42 AM
  • Hi Roy

    Thanks for showing your interest!

    I need to unlock the windows 10 device not UWP project.

    I am locking the system by using below code-

           private const int HWND_BROADCAST = 0xffff;
            private const int WM_SYSCOMMAND = 0x0112;
            private const int SC_MONITORPOWER = 0xF170;
            private const int SC_MONITORPOWER_OFF = 2;

            [DllImport("user32.dll")]
            public static extern IntPtr SendMessageW(int hWnd, uint Msg, int wParam, int lParam);

     

    var t = SendMessageW(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, SC_MONITORPOWER_OFF);

    But not able to unlock the system automatically (Our windows 10 device dont have password to unlock they have only 1 admin user without password. ) 



    sandeep chauhan


    Wednesday, November 28, 2018 10:51 AM
  • Hi,

    UWP does not provide an API to unlock the system, I am not sure if there is a similar API on the desktop application, if you want to know more, it will be more appropriate to ask your question at Visual C# forum for dedicated information.

    Regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 29, 2018 5:47 AM
  • Hi

    I am developing the UWP app where I need to lock the system and automatically unlock the system on WNS PUSH receive.

    I am only able to lock the system but not able to unlock automatically, its getting unlock when we press any key or move mouse.

    Is there any way to do the same? Can we do it through console app? (we can call console through Desktop Bridge feature).

    OR

    Same apply for sleep mode. we can sleep but we cant wake up. any way to do the same through UWP or through console app ?


    sandeep chauhan

    Friday, November 30, 2018 6:35 AM
  • No.  There is no API to unlock the workstation.  The user must do it in person.

    Clearly, you can't wake the system from sleep, because your code is no longer running.  Wake-from-sleep has to be triggered by hardware.  It is possible to use ACPI to program the system BIOS to wake the system after a certain amount of time.  In a non-UWP app, you can do that with the SetWaitableTimer API.  UWP apps do not have that ability.

    So, I guess you are 0 for 2.


    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Saturday, December 1, 2018 12:13 AM
  • Hi Sandeep_chauhan,

    This is forum discusses and asks questions about the C# programming language, since your issue is more related to UWP, I'll move it to UWP forum for suitable support.

    Thanks for your understanding.

    Best reagrds,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 3, 2018 3:12 AM