how to sign out from windows 10 program in uwp?

☆樱花仙子☆ 提交于 2019-12-11 11:11:44

问题


how to log off(sign out) windows 10 using uwp? I have do in win-forms but codes are not working in uwp.

     [DllImport("user32.dll")]
        public static extern int ExitWindowsEx(int operationFlag, int rationReason);

  private void button_Click(object sender, RoutedEventArgs e)
        {
            //Application.Current.Exit();

            ExitWindowsEx(0, 0);
        }

回答1:


In non-UWP programme You can create a new process and run

%windir%\System32\shutdown.exe /l /t 0

But this is not available to UWP programmes. Check out the Stack Overflow link here for another take on this problem. But it looks like you are out of luck.




回答2:


As i see your code above , you are actually closing the application. In UWP , Application works on states like Activated, Running, Suspended or Exited If you want to log out from the application , it means that you would like to wipe of all user data and his Navigation History.

Make A function that clears the NavigationTrace and once the NavigationEntry is cleared , navigate the user to the login screen/home page



来源:https://stackoverflow.com/questions/36467844/how-to-sign-out-from-windows-10-program-in-uwp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!