说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

VB如何检查您的电脑是否打开 ActiveDesktop?

HTML文档下载 WORD文档下载 PDF文档下载
VB如何检查您的电脑是否打开 ActiveDesktop?
版本:VB6 / VB5 / VB4-32

在 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
备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘