Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. DLL won't phone home?

DLL won't phone home?

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    elbow
    wrote on last edited by
    #1

    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:

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups