Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

Application process not terminating on Win2000

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
nnbbb09
Asked:
nnbbb09
  • 5
  • 4
1 Solution
 
GloomyFriarCommented:
procedure TFormMain.FormDestroy(Sender: TObject);
begin
  while True do begin
    Application.ProcessMessages;
  end;
end;
0
 
GloomyFriarCommented:
The code is an example how it can occur.
0
 
GloomyFriarCommented:
So check all functions like OnDestroy, OnClose, ... and make sure that you stop all timers.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
nnbbb09Author Commented:
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
 
geobulCommented:
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
 
GloomyFriarCommented:
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
 
nnbbb09Author Commented:
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
 
GloomyFriarCommented:
>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
 
nnbbb09Author Commented:
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
 
nnbbb09Author Commented:

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now