Solved

Application process not terminating on Win2000

Posted on 2003-10-29
11
220 Views
Last Modified: 2010-04-05
Does anyone know of any reason why an application process written with delphi6 will not terminate correctly? It uses the BDE to access Paradox tables and does not use any threads.
The problem only occurs on certain Win2k machines, but does not display any error message. We do use the OneInst.pas unit which uses a mutex to prevent multiple instances of the application from running. This results in the user having to manually kill the process before the app can be re-run.

Thanks

Jo Beaven
CharitySoftware Ltd
0
Comment
Question by:nnbbb09
  • 5
  • 4
11 Comments
 
LVL 6

Expert Comment

by:GloomyFriar
Comment Utility
procedure TFormMain.FormDestroy(Sender: TObject);
begin
  while True do begin
    Application.ProcessMessages;
  end;
end;
0
 
LVL 6

Expert Comment

by:GloomyFriar
Comment Utility
The code is an example how it can occur.
0
 
LVL 6

Expert Comment

by:GloomyFriar
Comment Utility
So check all functions like OnDestroy, OnClose, ... and make sure that you stop all timers.
0
 
LVL 3

Author Comment

by:nnbbb09
Comment Utility
All timers are definitely stopped. It seems like a Win2000 permissions problem. If the application is run with admin rights then the problem does not occur.
0
 
LVL 17

Expert Comment

by:geobul
Comment Utility
Hi,

Try without mutexes this way:
---
give your main form a Custom Class name and do FindWindow for that Class name.

program Project1;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.RES}

begin
  if FindWindow('I Am Mostly Asleep', nil) <> 0 then exit;

  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

and in your main form's code -

 protected
 { Protected declarations }
   procedure CreateParams(var Params: TCreateParams); override;

procedure TForm1.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.WinClassName := 'I Am Mostly Asleep';
  {set your Form's Class Name to a UNIQUE and UNCOMMON string, Like Drt45v6Z2}
end;

Regards, Geo
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 6

Expert Comment

by:GloomyFriar
Comment Utility
By the way how many threads the Task Manager show for your program when it is gone to background?

>If the application is run with admin rights then the problem does not occur.
It's rather strange. Can you find the problem code in debugger, going step-by-step?
0
 
LVL 3

Author Comment

by:nnbbb09
Comment Utility
I can't recreate the problem on the machines here, it only seems to occur on customer machines. I can't see the number of threads per process only the total running for the operation system.

As I said earlier it looks like a permissions problem as it doesn't occur for someone with admin rights. Any idea what kind of permissions I could set on my PC to replicate this problem.

Thanks
0
 
LVL 6

Expert Comment

by:GloomyFriar
Comment Utility
>As I said earlier it looks like a permissions problem
May be it's a permissions problem but "locally".
In "global" it means (imho) that there is some kind of infinite cycle occur when the application stop.
Add to the application some kind of logging to find the problem code.
0
 
LVL 3

Accepted Solution

by:
nnbbb09 earned 0 total points
Comment Utility
After much debugging of the VCL it seems the DBIExit called from the Finalization section of DBTables was causing the problem. Apparently this forces the BDE to write changes to HKEY_LOCAL_MACHINE\Software\Borland (which the user doesn't have access to) hence the application hangs.

I used regedt32 to grant access to that key and it works fine now.
0
 
LVL 3

Author Comment

by:nnbbb09
Comment Utility

I'm going to ask Support to PAQ this as I answered it myself. Any objections, please list them here.

Thanks

Jo
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 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

10 Experts available now in Live!

Get 1:1 Help Now