Click here to Skip to main content
15,850,265 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Receive UDP packet from multiple default gateway Pin
Shanky426-Mar-14 7:55
Shanky426-Mar-14 7:55 
GeneralRe: Receive UDP packet from multiple default gateway Pin
Shanky426-Mar-14 8:05
Shanky426-Mar-14 8:05 
GeneralRe: Receive UDP packet from multiple default gateway Pin
Richard MacCutchan26-Mar-14 8:14
mveRichard MacCutchan26-Mar-14 8:14 
AnswerRe: Receive UDP packet from multiple default gateway Pin
Jochen Arndt26-Mar-14 8:17
professionalJochen Arndt26-Mar-14 8:17 
GeneralRe: Receive UDP packet from multiple default gateway Pin
Shanky426-Mar-14 8:29
Shanky426-Mar-14 8:29 
QuestionADO Connection ptr under Windows 7 fails in Windowx XP Pin
aaandrei26-Mar-14 5:55
aaandrei26-Mar-14 5:55 
AnswerRe: ADO Connection ptr under Windows 7 fails in Windowx XP Pin
Jochen Arndt26-Mar-14 6:07
professionalJochen Arndt26-Mar-14 6:07 
QuestionHow to use global hook with WH_GETMESSAGE Pin
cedricvictor26-Mar-14 3:44
cedricvictor26-Mar-14 3:44 
Dear all:

I try to use global hook with WH_GETMESSAGE, but still failed.

It work only on my application, not global. My code show as below:

C++
#pragma data_seg (".SHARED")
    HHOOK g_hPreviousMsgHook = 0;
    HINSTANCE g_hInstance = 0;
#pragma data_seg()
#pragma comment(linker, "/SECTION:.SHARED,RWS")


C++
BOOL CSoundDllApp::InitInstance()
{
    CWinApp::InitInstance();
    g_hInstance = AfxGetInstanceHandle();
    return TRUE;
}



C++
BOOL InstallWinHook()
{
    BOOL bReturn = TRUE;
    g_hPreviousMsgHook = SetWindowsHookEx(WH_GETMESSAGE, 
                             &MsgHookProcedure, g_hInstance, 0);
 
    if(NULL == g_hPreviousMsgHook)
    {
        bReturn = FALSE;
    }
    return bReturn;
}


C++
LRESULT CALLBACK MsgHookProcedure(int nCode, WPARAM wParam, LPARAM lParam)
{
    if(0 > nCode)
        return CallNextHookEx(g_hPreviousMsgHook, nCode, 
                                         wParam, lParam);
    PMSG data = (PMSG)lParam;

    switch(data->message)
    {
    case WM_POINTERDOWN:
       Beep(0x7fff, 1000);
    break;
    }
    return CallNextHookEx(g_hPreviousMouseHook, nCode, wParam,   
                                                 lParam);
}


I set 0 into last parameter of setWindowsHookEx api, but it seem like not work.

Could someone tell me where's wrong, please?

Thanks for your help, Victor
AnswerRe: How to use global hook with WH_GETMESSAGE Pin
Richard MacCutchan26-Mar-14 6:26
mveRichard MacCutchan26-Mar-14 6:26 
GeneralRe: How to use global hook with WH_GETMESSAGE Pin
cedricvictor26-Mar-14 17:57
cedricvictor26-Mar-14 17:57 
GeneralRe: How to use global hook with WH_GETMESSAGE Pin
Richard MacCutchan26-Mar-14 23:52
mveRichard MacCutchan26-Mar-14 23:52 
Questionstd::wcout can't print out Arabic chars and some mathmatical symbols Pin
Falconapollo26-Mar-14 0:59
Falconapollo26-Mar-14 0:59 
QuestionWhich among following statements c/c++ code is faster? Pin
shaktikanta24-Mar-14 23:59
shaktikanta24-Mar-14 23:59 
AnswerRe: Which among following statements c/c++ code is faster? Pin
Jochen Arndt25-Mar-14 1:20
professionalJochen Arndt25-Mar-14 1:20 
GeneralRe: Which among following statements c/c++ code is faster? Pin
Heng Xiangzhong10-Apr-14 2:19
Heng Xiangzhong10-Apr-14 2:19 
AnswerRe: Which among following statements c/c++ code is faster? Pin
Maximilien25-Mar-14 2:01
Maximilien25-Mar-14 2:01 
GeneralRe: Which among following statements c/c++ code is faster? Pin
shaktikanta25-Mar-14 4:18
shaktikanta25-Mar-14 4:18 
GeneralRe: Which among following statements c/c++ code is faster? Pin
Maximilien25-Mar-14 4:32
Maximilien25-Mar-14 4:32 
GeneralRe: Which among following statements c/c++ code is faster? Pin
jschell25-Mar-14 14:26
jschell25-Mar-14 14:26 
JokeRe: Which among following statements c/c++ code is faster? Pin
Rage25-Mar-14 3:20
professionalRage25-Mar-14 3:20 
AnswerRe: Which among following statements c/c++ code is faster? Pin
Albert Holguin25-Mar-14 5:42
professionalAlbert Holguin25-Mar-14 5:42 
AnswerRe: Which among following statements c/c++ code is faster? Pin
ptse26-Mar-14 4:34
ptse26-Mar-14 4:34 
GeneralRe: Which among following statements c/c++ code is faster? Pin
Richard MacCutchan26-Mar-14 6:24
mveRichard MacCutchan26-Mar-14 6:24 
QuestionFree fails with access violation Pin
tejaswini_g24-Mar-14 17:14
tejaswini_g24-Mar-14 17:14 
AnswerRe: Free fails with access violation Pin
Richard MacCutchan24-Mar-14 23:52
mveRichard MacCutchan24-Mar-14 23:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.