本文介绍了我的代码中检测屏幕保护程序有什么问题!!!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,如果屏幕保护程序在应用程序运行时处于活动状态,我想运行登录表单.但是当我运行该应用程序时,例如在1分钟后,屏幕保护程序处于活动状态,该应用程序未检测到它并且没有执行任何操作!我的代码有什么问题?
这是代码:

in my project i want to run login form if the screen saver be active while the application is running. but when i run the application and after for example 1 minute, the screen saver be active, the application doesnt detect it and doesnt do any thing !!!!!
what''s wrong in my code??
this is the code :

Partial Friend Class MyApplication


        Public WithEvents idleTimer As Timer

        Private Declare Function SystemParametersInfo _
     Lib "user32" _
     Alias "SystemParametersInfoA" _
       (ByVal uiAction As Long, _
        ByVal uiParam As Long, _
        ByVal pvParam As Long, _
        ByVal fWInIni As Long) As Boolean

        Private Const SPI_GETSCREENSAVEACTIVE As Long = &H10
        Public Const SPI_GETSCREENSAVERRUNNING As Long = &H72


        Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup

            idleTimer = New Timer
            idleTimer.Interval = 10000
            idleTimer.Start()

        End Sub

        Private Sub idleTimer_Tick() Handles idleTimer.Tick

            Dim bRunning As Boolean
            SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, bRunning, False)

            If bRunning Then
                Dim frm1 As New frmLogin()
                frm1.ShowDialog()

            Else
                idleTimer.Stop()
                idleTimer.Start()

            End If

        End Sub

    End Class

推荐答案

Private Declare Function SystemParametersInfo _
     Lib "user32" _
     Alias "SystemParametersInfoA" _
       (ByVal uiAction As Long, _
        ByVal uiParam As Long, _
        ByRef pvParam As Long, _
        ByVal fWInIni As Long) As Boolean



除了我的评论外,我还会试一试. :)



In addition to my comment, I would give that a shot. :)


这篇关于我的代码中检测屏幕保护程序有什么问题!!!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 21:53
查看更多