Article View: borland.public.cppbuilder.nativeapi
Article #2303Re: My app closes, but cancels Windows shutdown?
From: Remy Lebeau (TeamB)
Date: Sat, 10 Mar 2007 21:51
Date: Sat, 10 Mar 2007 21:51
36 lines
2718 bytes
2718 bytes
"A Nonymous" <anonymous@hotmail.com> wrote in message
news:Xns98EF8B2886544anonymoushotmailcom@207.105.83.66...
> I did some reading and a null return is a failure
Yes, it is. The weird thing is, when I run the exact code I gave you,
SetWindowsHookEx() does not return NULL, so it is not failing for me.
> I added a call to GetLastError() and found that the error is
> 1428 "Cannot set non-local hook without a module handle".
The thing is, the key to this approach is to install a local hook, so
that a DLL is not needed. What you could try doing is to pass the
return value of GetCurrentThreadId() to the dwThreadId parameter of
SetWindowsHookEx() instead of using a module handle, ie:
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
hHook = SetWindowsHookEx(WH_CALLWNDPROCRET,
(HOOKPROC)&CallWndRetProc, NULL, GetCurrentThreadId());
// ...
return 0;
}
If you have any worker threads that create windows, then they would
need their own local hooks, though.
> I changed the line:
<snip>
> and now when I run, the entire IDE dissapears! WOW!
I cannot reproduce that behavior.
Gambit
Technical Details
Message-ID:
<45f3285b$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<Xns98ED90968E734anonymoushotmailcom@207.105.83.66> <45f07307@newsgroups.borland.com> <Xns98ED988E421A8anonymoushotmailcom@207.105.83.66> <45f08f8f$1@newsgroups.borland.com> <Xns98EDAC20DAA4Eanonymoushotmailcom@207.105.83.66> <45f095bf$1@newsgroups.borland.com> <45f0a594@newsgroups.borland.com> <45f0a77f$1@newsgroups.borland.com> <45f0d6c1@newsgroups.borland.com> <Xns98EE722D896C6anonymoushotmailcom@207.105.83.66> <45f1a96b$1@newsgroups.borland.com> <Xns98EE9F12960D1anonymoushotmailcom@207.105.83.66> <45f1d8a5$1@newsgroups.borland.com> <Xns98EEAB7C7DA52anonymoushotmailcom@207.105.83.66> <45f1ffc0$1@newsgroups.borland.com> <Xns98EF8B2886544anonymoushotmailcom@207.105.83.66>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,346f60f70c29a156 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <Xns98ED90968E734anonymoushotmailcom@207.105.83.66> <45f07307@newsgroups.borland.com> <Xns98ED988E421A8anonymoushotmailcom@207.105.83.66> <45f08f8f$1@newsgroups.borland.com> <Xns98EDAC20DAA4Eanonymoushotmailcom@207.105.83.66> <45f095bf$1@newsgroups.borland.com> <45f0a594@newsgroups.borland.com> <45f0a77f$1@newsgroups.borland.com> <45f0d6c1@newsgroups.borland.com> <Xns98EE722D896C6anonymoushotmailcom@207.105.83.66> <45f1a96b$1@newsgroups.borland.com> <Xns98EE9F12960D1anonymoushotmailcom@207.105.83.66> <45f1d8a5$1@newsgroups.borland.com> <Xns98EEAB7C7DA52anonymoushotmailcom@207.105.83.66> <45f1ffc0$1@newsgroups.borland.com> <Xns98EF8B2886544anonymoushotmailcom@207.105.83.66> Subject: Re: My app closes, but cancels Windows shutdown? Date: Sat, 10 Mar 2007 13:51:29 -0800 Lines: 38 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 75.83.34.171 Message-ID: <45f3285b$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1173563483 75.83.34.171 (10 Mar 2007 13:51:23 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail