Click here to Skip to main content
16,011,374 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Is allocated`????? Pin
Nish Nishant10-Mar-02 21:27
sitebuilderNish Nishant10-Mar-02 21:27 
GeneralRe: Is allocated`????? Pin
[James Pullicino]11-Mar-02 0:31
[James Pullicino]11-Mar-02 0:31 
GeneralRe: Is allocated`????? Pin
Tim Smith11-Mar-02 2:10
Tim Smith11-Mar-02 2:10 
GeneralRe: Is allocated`????? Pin
[James Pullicino]11-Mar-02 2:59
[James Pullicino]11-Mar-02 2:59 
GeneralTo truncate a large Pin
tfElep10-Mar-02 20:13
tfElep10-Mar-02 20:13 
GeneralRe: To truncate a large Pin
Michael Dunn10-Mar-02 20:39
sitebuilderMichael Dunn10-Mar-02 20:39 
GeneralRe: To truncate a large Pin
Jeason Zhao10-Mar-02 20:44
Jeason Zhao10-Mar-02 20:44 
QuestionDLL won't phone home? Pin
elbow10-Mar-02 19:42
elbow10-Mar-02 19:42 
I have a hook dLL that I'd like to send a message back to the calling app.

Something like......

keyboard hook detects that F2 is pressed

dLL sends message to app

app shows dialog

main code in dLL as follows

///////////////////////////////////////////////////////////
#define WM_APPSTARTED WM_USER + 100



#pragma data_seg(".shared")

HWND g_mainWnd = NULL; //the server window handle

HHOOK g_hShellHook = NULL;

HHOOK g_hKeyboard = NULL;

#pragma data_seg()

#pragma comment(linker, "section:.shared,rws")




SYSDLL_API BOOL _Startup(HWND hwnd)

{

g_hKeyboard = NULL;

g_mainWnd = hwnd; // g_mainWnd is the main window handle


g_hKeyboard = SetWindowsHookEx(WH_KEYBOARD, MyProc, g_hInstance, 0);


if(g_hKeyboard == NULL)

MessageBox(HWND_DESKTOP, "hook fail", "BLAH", MB_OK);



if(g_mainWnd != NULL)

return FALSE; // already hooked!


g_hShellHook = SetWindowsHookEx(WH_SHELL, MyShellProc,g_hInstance, 0);

if(g_hShellHook != NULL)

{
g_mainWnd = hwnd;

return TRUE;

}

return FALSE;

}

SYSDLL_API LRESULT CALLBACK MyShellProc(int ncode, WPARAM wparam, LPARAM lparam)
{

if(ncode < 0 )

return CallNextHookEx(g_hShellHook, ncode, wparam, lparam);




if(ncode == HSHELL_WINDOWCREATED)

{

HWND hfoundApp;

hfoundApp = FindWindow(NULL, TEXT("my_window" ) );

if(hfoundApp)
{

PostMessage(hfoundApp, WM_APPSTARTED, lparam, wparam);

}


}

this is where I'd like the dLL to send a message to the callin app

but the message never gets to the app


thanks for your time















Confused | :confused:
Generaltab controls in MFC Pin
10-Mar-02 19:27
suss10-Mar-02 19:27 
GeneralA question on CListCtrl Pin
10-Mar-02 19:11
suss10-Mar-02 19:11 
GeneralRe: A question on CListCtrl Pin
Derek Waters10-Mar-02 19:16
Derek Waters10-Mar-02 19:16 
QuestionCan i download the faq of this message board? Pin
10-Mar-02 18:15
suss10-Mar-02 18:15 
AnswerRe: Can i download the faq of this message board? Pin
Christian Graus10-Mar-02 18:45
protectorChristian Graus10-Mar-02 18:45 
AnswerRe: Can i download the faq of this message board? Pin
Nish Nishant10-Mar-02 19:02
sitebuilderNish Nishant10-Mar-02 19:02 
GeneralRe: Can i download the faq of this message board? Pin
10-Mar-02 22:19
suss10-Mar-02 22:19 
GeneralRe: Can i download the faq of this message board? Pin
Nish Nishant10-Mar-02 22:16
sitebuilderNish Nishant10-Mar-02 22:16 
GeneralCOM Pin
StuartHall10-Mar-02 18:10
StuartHall10-Mar-02 18:10 
GeneralRe: COM Pin
Paul M Watt10-Mar-02 18:15
mentorPaul M Watt10-Mar-02 18:15 
Generalunexpected results Pin
Mohe10-Mar-02 18:04
Mohe10-Mar-02 18:04 
GeneralRe: unexpected results Pin
Paul M Watt10-Mar-02 18:23
mentorPaul M Watt10-Mar-02 18:23 
GeneralModifying Environment Variables Pin
v_krishnan10-Mar-02 17:36
v_krishnan10-Mar-02 17:36 
GeneralRe: Modifying Environment Variables Pin
Lim Bio Liong10-Mar-02 20:48
Lim Bio Liong10-Mar-02 20:48 
GeneralWorkerThread + ProgressDlg Pin
Peter Molnar10-Mar-02 13:55
Peter Molnar10-Mar-02 13:55 
GeneralRe: WorkerThread + ProgressDlg Pin
Todd Smith10-Mar-02 14:00
Todd Smith10-Mar-02 14:00 
GeneralRe: WorkerThread + ProgressDlg Pin
Peter Molnar10-Mar-02 14:04
Peter Molnar10-Mar-02 14:04 

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.