Hi,

I have written a WH_CBT hook handling code and it works OK except for where Code = WHCBT_SYSCOMMAND...which causes a GPF.

The code (snippet) is ...
Code:
Case HOOKPROC_CBT '<--CBT Hook is triggered
    Code = Arguments(1)
    wParam = Arguments(2)
    lParam = Arguments(3)
    Select Case Code '<--What type of message?
    '....
    Case     Case Code = HCBT_SYSCOMMAND
        Dim ptMouse As New APIPoint
        Dim activeBy As SystemCommandActivationMethods
        Select Case APIDispenser.HiWord(lParam)
        Case 0
            activeBy = SCAM_BYMNEMONIC
        Case -1
            activeBy = SCAM_BYSYSACCELERATOR
        Case Else
            activeBy = SCAM_BYMOUSE
            ptMouse.y = APIDispenser.HiWord(lParam)
            ptMouse.x = APIDispenser.LoWord(lParam)
        End Select
        '\ Only the upper 3 bytes are used - the lower 4 are reserved for the system...
        wParam = (wParam And &HFFF0)
        Select Case wParam
        Case SC_HOTKEY
            '\ A window is being activated by a hotkey
            wndThis.hWnd = lParam
            RaiseEvent ActivateWindowByHotkey(wndThis, Cancel)
        Case SC_TASKLIST
            RaiseEvent StartMenu(activeBy, ptMouse, Cancel)
        Case SC_MONITORPOWER
            If lParam = 1 Then
                RaiseEvent MonitorLowPower(activeBy, ptMouse, Cancel)
            ElseIf lParam = 2 Then
                RaiseEvent MonitorPowerOff(activeBy, ptMouse, Cancel)
            End If
        Case SC_CONTEXTHELP
            RaiseEvent InitiateContextHelp(activeBy, ptMouse, Cancel)
        '.......
        End Select
        If Cancel Then
            Arguments(4) = 1
        End If
     '.......
Does anybody have any experience of this hook proc that could guide me to finding the source of the GPF?

Many many many thanks in advance,
Duncan