如题
就是判断现在显示的是xp桌面,如何操作,谢谢
(不是判断活动窗口哈)

解决方案 »

  1.   

    我用类名不同的情况得到的活动窗体句柄不一致啊,帮我看下,怎么回事,
    按下快速启动显示桌面,或者在点击一下已经打开的文件夹,在点击快速启动的显示桌面值不一致,怎么判断呢,我想要一个效果就是,按下显示桌面(快速启动的或者win+d键)都能检测到,然后采取操作
    Private Declare Function GetForegroundWindow Lib "user32" () As Long
    Private Declare Function GetActiveWindow Lib "user32" () As Long
    Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As LongPrivate Const HWND_TOPMOST = -1
    Private Const HWND_NOTOPMOST = -2Private Const SWP_NOMOVE = &H2
    Private Const SWP_NOSIZE = &H1Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As LongPrivate Declare Function GetDesktopWindow Lib "user32" () As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Sub Form_Load()
     Timer1.Interval = 500
     SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE '置顶
    End SubPrivate Sub Timer1_Timer()
    Dim hwnd As Long, hwnd1 As Long, hwnd2 As Long
    Dim str1 As String
    hwnd = GetForegroundWindow
    hwnd1 = FindWindow("SysListView32", "")
    hwnd2 = GetActiveWindow
    Me.Caption = "hwnd:" & hwnd & ",hwnd1:" & hwnd1 & ",hwnd2:" & hwnd2
    str1 = Space(100)
    GetWindowText hwnd, str1, 100
    str1 = Trim(str1)
    Text1.Text = str1
    Text2.Text = GetDesktopWindowEnd Sub
      

  2.   

    API函数:GetDeskTopWindow可以实现
      

  3.   

    win + D用HOOk试下,快速启动,其实是一个文件的快捷方式,对文件进行监控下,试下仅仅是个建议,试下