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
U

User 1492767

@User 1492767
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Hooks (WH_CALLWNDPROC)
    U User 1492767

    Thanks for the excellent suggestions. Works great now

    C / C++ / MFC ios performance help question

  • Hooks (WH_CALLWNDPROC)
    U User 1492767

    Hi guys, I'm writing a program that should monitor the "active" application's copying and pasting.I decided on using use a system-wide WH_CBTPROC hook and a thread-specific WH_CALLWNDPROC hook to capture the WM_PASTE and WM_COPY messages. The hooking works OK, the problem is that the WH_CALLWNDPROC causes the menus in "Microsoft Word" not to display. Am i using the hook wrong? (Maybe not passing the messages along). And it makes the programs realllllyy slowww. I'm running a Duron 800mhz, should it have such a big influence on performance? Any Ideas? Thanks The base code looks like this. HINSTANCE hins; HHOOK hmsg = NULL; HHOOK hcbt = NULL; BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { hins=(HINSTANCE)hModule; switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } //--------------------------------------------------------------------------- LRESULT CALLBACK MsgProc(int nCode, WPARAM wParam, LPARAM lParam) { char *file = new char[100]; file = "c:\\test.txt"; fstream out(file,ios::out | ios::app); if (nCode < 0) { LRESULT RetVal = CallNextHookEx( hmsg, nCode, wParam, lParam ); return RetVal; } if (HC_ACTION==nCode) { CWPSTRUCT *msgInfo = (CWPSTRUCT*)lParam; switch (msgInfo->message) { case WM_COPY: out << "COPY" << endl; break; case WM_PASTE: out << "PASTE" << endl; break; } } LRESULT RetVal = CallNextHookEx( hmsg, nCode, wParam, lParam ); return RetVal; } //--------------------------------------------------------------------------- LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam) { char *file = new char[100]; file = "c:\\test.txt"; fstream out(file,ios::out | ios::app); DWORD ProcessId; char szModName[MAX_PATH]; HWND current_window; HANDLE hProcess; SYSTEMTIME SystemTime; if (nCode == HCBT_ACTIVATE) { current_window = (HWND)wParam; GetWindowThreadProcessId( current_window,&ProcessId); hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, ProcessId ); int length = GetModuleFileNameEx( hProcess, NULL, szModName,sizeof(szModName)); out << szModName << endl; if (hmsg == NULL) { hms

    C / C++ / MFC ios performance help question
  • Login

  • Don't have an account? Register

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