Click here to Skip to main content
15,925,400 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to remove splash using the commandline? Pin
Joan M2-Mar-01 16:15
professionalJoan M2-Mar-01 16:15 
AnswerRe: How to remove splash using the commandline? Pin
2-Mar-01 16:48
suss2-Mar-01 16:48 
GeneralRe: How to remove splash using the commandline? Pin
2-Mar-01 19:06
suss2-Mar-01 19:06 
GeneralRe: How to remove splash using the commandline? Pin
l a u r e n3-Mar-01 7:55
l a u r e n3-Mar-01 7:55 
QuestionCtrl+Alt+Del almost OK, but not 100% could you take a look at it? Pin
Joan M2-Mar-01 16:13
professionalJoan M2-Mar-01 16:13 
AnswerRe: Ctrl+Alt+Del almost OK, but not 100% could you take a look at it? Pin
Tim Deveaux3-Mar-01 3:23
Tim Deveaux3-Mar-01 3:23 
GeneralRe: Ctrl+Alt+Del almost OK, but not 100% could you take a look at it? Pin
Joan M3-Mar-01 3:31
professionalJoan M3-Mar-01 3:31 
GeneralRe: Ctrl+Alt+Del almost OK, but not 100% could you take a look at it? Pin
Tim Deveaux3-Mar-01 13:39
Tim Deveaux3-Mar-01 13:39 
Ah - well, a nice thankyou deserves some extra effort! Smile | :)

I found two problems with your approach - first, you must be careful with the hInstance - if your hook is in the application from which its called (not a DLL) use NULL.

Second, the handle that is passed to CallNextHookEx must be shared amongst all applications, and I think this is what was causing the (very noticicable) crashes.

Here's my stab at it - if you create a header file containing this code and a def file containing the SECTIONS statement as shown and include them in your project, you can include the header (once) and you have a system wide keyboard hook.

I think it still only gets the ctrl.alt.del after the system does, but you can play. HTH

// include this header only once - and create and 
// include a def file in your project - e.g.
 
/*
; TestHook2 : Declares the module parameters.
 
SECTIONS .Whatever READ WRITE SHARED
*/
 
LRESULT CALLBACK HookDeMostrarFinestres(int nCode, WPARAM wParam, LPARAM lParam);
 
// you must define a segment as SHARED in  the .def file...
#pragma data_seg (".Whatever")        
// one instance for all processes
HHOOK   g_hHookMostrarFinestres = NULL; 
#pragma data_seg ()
 
 
class CCaptain {
private:
public:
    // public member declarations
    CCaptain();
    virtual ~CCaptain();
};
 
CCaptain::CCaptain(){
   g_hHookMostrarFinestres =
   SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)HookDeMostrarFinestres,NULL,NULL);
}
 
CCaptain::~CCaptain(){
    UnhookWindowsHookEx(g_hHookMostrarFinestres);
}
 
LRESULT CALLBACK HookDeMostrarFinestres(int nCode, WPARAM wParam, LPARAM lParam)
{ 
    MessageBeep(-1);
    if (nCode == HC_ACTION) { MessageBeep(-1); }  // will beep twice...
    return CallNextHookEx(g_hHookMostrarFinestres, nCode, wParam, lParam);
}
 
// declare the hook - so all you do is include this file (once)
static  CCaptain Hook;


Oops - forgot to mention - I tested this on Win98 only! Don't know if it will work on NT...

=================
later...
Oops - one more goof - just tested a release build, where it works - but only when the app containing the hook has focus. Dang. Oh well... hope it helps the crash problem anyway...
GeneralRe: Ctrl+Alt+Del almost OK, but not 100% could you take a look at it? Pin
Tim Deveaux5-Mar-01 7:39
Tim Deveaux5-Mar-01 7:39 
AnswerRe: Ctrl+Alt+Del almost OK, but not 100% could you take a look at it? Pin
l a u r e n3-Mar-01 11:14
l a u r e n3-Mar-01 11:14 
AnswerRe: Ctrl+Alt+Del almost OK, but not 100% could you take a look at it? Pin
Erik Funkenbusch5-Mar-01 10:28
Erik Funkenbusch5-Mar-01 10:28 
Generaldata between classes Pin
2-Mar-01 15:54
suss2-Mar-01 15:54 
GeneralRe: data between classes Pin
l a u r e n3-Mar-01 4:23
l a u r e n3-Mar-01 4:23 
Generalsetting active partition Pin
2-Mar-01 12:48
suss2-Mar-01 12:48 
GeneralRe: setting active partition Pin
l a u r e n3-Mar-01 7:52
l a u r e n3-Mar-01 7:52 
GeneralCFile::Read Pin
Vickie2-Mar-01 8:25
Vickie2-Mar-01 8:25 
GeneralRe: CFile::Read Pin
Daniel Ferguson2-Mar-01 9:44
Daniel Ferguson2-Mar-01 9:44 
GeneralPLEEEASE!!! HELP ME NOW OR I'M FIRED!!! HOW DO I... Pin
2-Mar-01 7:24
suss2-Mar-01 7:24 
GeneralRe: PLEEEASE!!! HELP ME NOW OR I'M FIRED!!! HOW DO I... Pin
l a u r e n2-Mar-01 10:39
l a u r e n2-Mar-01 10:39 
GeneralRe: PLEEEASE!!! HELP ME NOW OR I'M FIRED!!! HOW DO I... Pin
Tim Deveaux2-Mar-01 10:55
Tim Deveaux2-Mar-01 10:55 
GeneralRe: PLEEEASE!!! HELP ME NOW OR I'M FIRED!!! HOW DO I... Pin
Christian Graus2-Mar-01 12:19
protectorChristian Graus2-Mar-01 12:19 
GeneralUppercase --- Urgent Pin
2-Mar-01 6:34
suss2-Mar-01 6:34 
GeneralRe: Uppercase --- Urgent Pin
Chris Losinger2-Mar-01 7:55
professionalChris Losinger2-Mar-01 7:55 
GeneralRe: Uppercase --- Urgent Pin
Daniel Ferguson2-Mar-01 9:30
Daniel Ferguson2-Mar-01 9:30 
GeneralCSplitterWnd and CMDIFrameWnd Pin
Sjoerd van Leent2-Mar-01 4:35
Sjoerd van Leent2-Mar-01 4:35 

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.