Article View: borland.public.cppbuilder.nativeapi
Article #1010WM_QUIT and Hook
From: Patryk B.
Date: Wed, 31 Oct 2007 10:35
Date: Wed, 31 Oct 2007 10:35
53 lines
1965 bytes
1965 bytes
Im traying to prevent to close my application.
I know its function OnCloseQuery but i want to prevent closing
from Task Manager too.
In know that global hook should be placed in DLL.
But I want hook only for my application.
What is wrong? It dont detect WM_QUIT.
Form6.cpp:
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode < 0)
{
return CallNextHookEx(hWin, nCode, wParam, lParam);
}
if(nCode==HC_ACTION)
{
PMSG msg;
msg = (PMSG)lParam;
if(msg->message==WM_QUIT)
{
ShowMessage("WM_QUIT detected!");
}
}
return CallNextHookEx(hWin, nCode, wParam, lParam);
}
void __fastcall TForm6::Button1Click(TObject *Sender)
{
hWin= SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)GetMsgProc, NULL,
GetWindowThreadProcessId(this->Handle, NULL));
if(hWin==NULL)
{
ShowMessage("Couldnt set hook");
}
}
void __fastcall TForm6::Button2Click(TObject *Sender)
{
if(hWin)
{
UnhookWindowsHookEx(hWin);
hWin=NULL;
}
}
Patryk B.
Technical Details
Message-ID:
<op.t0140zizwzezly@dune.intranet>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,611b8a70eeab8356,start X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Wed, 31 Oct 2007 11:35:13 +0100 Subject: WM_QUIT and Hook Reply-To: pbobak@no.spam.o2.pl From: "Patryk B." <pbobak@no.spam.o2.pl> Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-2 MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Content-Transfer-Encoding: Quoted-Printable Message-ID: <op.t0140zizwzezly@dune.intranet> User-Agent: Opera Mail/9.24 (Win32) NNTP-Posting-Host: 195.116.247.227 X-Trace: newsgroups.borland.com 1193826935 195.116.247.227 (31 Oct 2007 03:35:35 -0700) Lines: 53 Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail