Detecting if Windows Login Screen is visible to user in VB.NET

ε祈祈猫儿з 提交于 2019-12-12 04:15:33

问题


Hey StackOverflow VB.NET members,

After running the following code (which locks the computer), what code must I be applying to see if the user has successfully logged into the computer and that "Lock Screen" I'd so called has disappeared?

Private Declare Function LockWorkStation Lib "user32.dll" () As Long

Private Function LockComputer()
    LockWorkStation()
End Function

I will call "LockComputer", after that what do I do to see if the Lock screen so called by this function (after say 2 minutes) has disappeared or is still there asking for the password from the user!

Thanks, Akshit Soota


回答1:


Take a look on this: http://msdn.microsoft.com/en-us/library/aa376875%28v=vs.85%29.aspx

There it says: There is no function you can call to determine whether the workstation is locked.

But:

To receive notification when the user logs in, use the WTSRegisterSessionNotification function to receive WM_WTSSESSION_CHANGE messages. You can use session notifications to track the desktop state so you know whether it is possible to interact with the user.




回答2:


Did you read this in the MSDN documentation of LockWorkstation API:

There is no function you can call to determine whether the workstation is locked. To receive notification when the user logs in, use the WTSRegisterSessionNotification function to receive WM_WTSSESSION_CHANGE messages.



来源:https://stackoverflow.com/questions/5787359/detecting-if-windows-login-screen-is-visible-to-user-in-vb-net

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