🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #7240

Trapping Messages Sent to a Service App

#7240
From: Daniel
Date: Tue, 22 Feb 2005 01:31
50 lines
2084 bytes
Hi,

This should be very simple, but I am not able to make it
work. Thus, some help would be very appreciated.

I am simply trying to trap messages in a service app. Thus if
WM_QUERYENDSESSION or WM_ENDSESSION is sent, I would like
to know so as to stop the user.

The code implementation I am trying is as follows:

In the ServiceStart function I am doing :
  	
  if( !FHandle )
  {
    FHandle = AllocateHWnd(MyWndProc);
  }

In the ServiceStop function I am doing:

  if( Fhandle )
    DeallocateHWnd(FHandle);

  FHandle = NULL;

Finally MyWndProc is defined and implemented as:

void __fastcall TLogOffSrv::MyWndProc(Messages::TMessage &Message) {
   if( Message.Msg == WM_QUERYENDSESSION || Message.Msg == WM_ENDSESSION )
   {
     if( !FLogOffAllowed)
     {
       AnsiOutputDebug("Not Allowed " +  IntToHex((int)Message.Msg, 2) );
       Message.Result = 1;
     }
   }
   else
   {
     AnsiOutputDebug("Other Message "  + IntToHex((int)Message.Msg, 2) );
     Message.Result = 0;
   }
}

Thank you

danieL.
Technical Details
Message-ID: <opsmkruygsoyenhq@development-ws2.comvision.intranet>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,f6cd5d765941c670,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: d.jimenez@comvision.net.au
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Trapping Messages Sent to a Service App
Date: Tue, 22 Feb 2005 12:31:36 +1100
From: Daniel <d.jimenez@comvision.net.au>
Organization: Comvision Pty Ltd
Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15
MIME-Version: 1.0
Content-Transfer-Encoding: Quoted-Printable
Message-ID: <opsmkruygsoyenhq@development-ws2.comvision.intranet>
User-Agent: Opera M2/7.54 (Win32, build 3929)
NNTP-Posting-Host: 203.51.23.185
X-Trace: newsgroups.borland.com 1109035937 203.51.23.185 (21 Feb 2005 17:32:17 -0800)
Lines: 53
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail