VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 如何检查您的电脑是否打开 ActiveDesktop?
发表评论(0)作者:, 平台:, 阅读:8442, 日期:2000-04-06
主题: 如何检查您的电脑是否打开 ActiveDesktop?

来源:VB Square

版本:VB6 / VB5 / VB4-32

资料整理:影子 VB爱好者乐园 yingzi007.126.com





在 IE4 及 IE5 中都有提供使用者选择是否安裝 ActiveDeskTop 的功能,這个我们在 VB 中也可以检测出來的!


首先,在表单声明区中声明以下二个 API Function:


Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _

(ByVal lpClassName As String, ByVal lpWindowName As String) As Long


Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _

(ByVal hWnd1 As Long, ByVal hWnd2 As Long, _

ByVal lpsz1 As String, ByVal lpsz2 As String) As Long


接着,继续在表单声明区中加入以下模块:


Public Function ISActiveDesktop() As Boolean

Dim retVal As Long

retVal = FindWindow("Progman", vbNullString)

retVal = FindWindowEx(retVal, 0&, "SHELLDLL_DefView", vbNullString)

retVal = FindWindowEx(retVal, 0&, "Internet Explorer_Server", vbNullString)

If retVal > 0 Then

ISActiveDesktop = True

Else

ISActiveDesktop = False

End If

End Function

接着,在表单的 Form_Load 事件中加入以下程序代码:

Private Sub Form_Load()

If ISActiveDesktop = True Then

MsgBox "您已打开 ActiveDesktop", 64, "检查 ActiveDesktop"

Else

MsgBox "您并沒有使用 ActiveDesktop", 64, "检查 ActiveDesktop"

End If

End Sub

好了,现在您只要一运行程序,您就可以看到結果了!