We have tried to shift all device/platform specific code in the application
out to a hardware abstraction library, and I'd like to shift the shutdown
message processing out to the library too.
On Desktop Windows I could use SetWindowsHookEx(WH_CALLWNDPROC ...) to hook
the app. main thread processing, however on Windows CE/Mobile
SetWindowsHookEx(CALLWNDPROC ...) is not supported. Hooking/"subclassing" the
app. main window message processing with a SetWindowLong() call aint going to
help me either as the message in question is not directed at any particular
window.
Anyone got any other ideas??
Thanks
Richard.
Paul T.
"Richard" <Ric...@discussions.microsoft.com> wrote in message
news:A30DA103-1ACF-4B1D...@microsoft.com...
My aim here is to wrap all the platform specific code in a hardware/platform
abstraction library and have everything "just work" by linking in the
library, rather than having to polute the main application code with platform
specific message handling.
thanks
Richard.
-----
// JournalHook.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
// Need some of the definitions from the SetWindowsHookEx area.
#include <pwinuser.h>
// Declare a couple of completely undocumented functions implemented in
// coredll.
HHOOK WINAPI QASetWindowsJournalHook(
int nFilterType,
HOOKPROC pfnFilterProc,
EVENTMSG *pfnEventMsg
);
BOOL WINAPI QAUnhookWindowsJournalHook(
int nFilterType
);
// Declare this global so that it stays around while the hook is connected.
EVENTMSG evtMsg;
HHOOK localHook = NULL;
DWORD msgCount = 0;
HANDLE hf = NULL;
LRESULT CALLBACK JournalRecordProc(int code, WPARAM wParam, LPARAM lParam)
{
msgCount += 1;
DEBUGMSG( 1, ( TEXT( "JournalRecordProc: code %d, wParam 0x%x, lParam
0x%x\r\n" ),
code, wParam, lParam ) );
DEBUGMSG( 1, ( TEXT( "JournalRecordProc: localHook = %d, msgCount =
%d\r\n" ),
localHook, msgCount ) );
// PGT: It looks to me from reading GWES that lParam here is actually
// going to be a pointer to the eventmsg structure.
EVENTMSG *e = (EVENTMSG*)lParam;
DWORD xlen;
char s[ 512 ];
sprintf( s, "message %d, wParam 0x%x, lParam 0x%x\r\n",
e->message, e->paramH, e->paramL, e->time );
WriteFile( hf, s, strlen( s ), &xlen, NULL );
return CallNextHookEx( localHook, code, wParam, lParam );
}
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
ZeroMemory(&evtMsg, sizeof(EVENTMSG));
// Create log file.
hf = CreateFile( _T( "\\msglog.txt" ),
GENERIC_READ | GENERIC_WRITE, 0,
NULL, CREATE_ALWAYS, 0, NULL );
// Connect the hook.
localHook = QASetWindowsJournalHook(WH_JOURNALRECORD,
JournalRecordProc, &evtMsg);
while ( msgCount < 50 )
{
Sleep( 100 );
}
// Disconnect the hook.
QAUnhookWindowsJournalHook(WH_JOURNALRECORD);
CloseHandle( hf );
return 0;
}
-----
Paul T.
"Richard" <Ric...@discussions.microsoft.com> wrote in message
news:32006D66-5913-42BB...@microsoft.com...
Just a thought....
Kind regards,
Rob.
www.robtso.nl