Solved

Application process not terminating on Win2000

Posted on 2003-10-29
11
223 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
ID: 9643151
procedure TFormMain.FormDestroy(Sender: TObject);
begin
  while True do begin
    Application.ProcessMessages;
  end;
end;
0
 
LVL 6

Expert Comment

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

Expert Comment

by:GloomyFriar
ID: 9643197
So check all functions like OnDestroy, OnClose, ... and make sure that you stop all timers.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 3

Author Comment

by:nnbbb09
ID: 9648672
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
ID: 9648734
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
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9649200
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
ID: 9672094
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
ID: 9672841
>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
ID: 9694657
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
ID: 10275110

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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