Solved

Error logout/shutdown Windows NT 4

Posted on 2001-07-13
8
188 Views
Last Modified: 2010-04-06
Hello,

If i run my Delphi program, windows(NT4 server/workstation) is unable to logout a user or to shutdown..!! All open programs will be closed except mine. When i manually close my program everything works fine.. Does anyone have an idea whats going wrong?

If you need more info let me know..!!

Thanks,

Vincent
0
Comment
Question by:Vincentg
  • 4
  • 3
8 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6280126
have you assigned a procedure on any forms-onclosequery event in your app, where allow-close is set to false?
0
 

Author Comment

by:Vincentg
ID: 6280156
I only use :

Procedure Tform1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action := CaNone;
Form1.hide;
end;

I already tried without this but the result is the same..!!

0
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 6280165
try listebning for WM_QUERYENDSESSION by adding this to your form:

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
   procedure WMQueryEndSession(var Msg: TWMQueryEndSession) ; message WM_QUERYENDSESSION ;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  ok_to_close : boolean;

implementation

{$R *.DFM}

procedure TForm1.WMQueryEndSession(var Msg: TWMQueryEndSession);
const
  CAN_SHUTDOWN = 0 ;
  DONT_SHUTDOWN = 1 ;
begin
  inherited ;
  if ok_to_close then {ok_to_close is the global boolean}
  Msg.Result := CAN_SHUTDOWN
  else {if ok_to_close has been set to false then we would get here}
    Msg.Result := DONT_SHUTDOWN ;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ok_to_close := true;
end;
0
 

Author Comment

by:Vincentg
ID: 6285077
He,

Thanks for replying, i intergrated your code in my program
but it still doesn't work. I don't understand why it is't close down when shutting down windows. Any other suggestion? if you need more info just let me know..

Thanks,
Vincent
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 17

Expert Comment

by:inthe
ID: 6286822
add a showmessage after in the WMQueryEndSession to see if your apps even getting the message.


kind of a last resort but one to try is to make a copy of your project and start deleting stuff until it works .

ps,
does it work on new blank project on your system?
if so it must be something in your code somewhere thats not letting go.
0
 

Author Comment

by:Vincentg
ID: 6287223
He,

Thanks for replying, i intergrated your code in my program
but it still doesn't work. I don't understand why it is't close down when shutting down windows. Any other suggestion? if you need more info just let me know..

Thanks,
Vincent
0
 
LVL 17

Expert Comment

by:inthe
ID: 6331770
only other idea is to assign one of these as meikl was mentioning "forms-onclosequery" and set canclose to true;
0
 

Author Comment

by:Vincentg
ID: 8172031
for trying ;-)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now