Initialization problems with hidden application

From: Perry Way (no.delphipro.spam_at_no.spam.earthlink.net)
Date: 01/13/04


Date: Tue, 13 Jan 2004 11:24:53 -0800

I have an application I've been writing as an interactive visual Server
application.

Now I am ready to implement the application, and I want to enable the Server
to run while hidden, so that the machine can be logged out and the
application can still perform.

Of course I've covered all the nitty gritty details associated to making an
interactive application non-interactive. I've got a command line parameter
that causes the Server to either show its main form or to hide it. How I
hide the application is in my project's unit/source. I left the normal
source Delphi creates for the project unit intact and if the application is
supposed to run hidden I execute other source. Below is an example..

program LiveWAIIServer;

uses
  ESEXERoutines,
  SysUtils,
  Forms,
  uServer in 'uServer.pas' {frmServer};

{$R *.res}

begin
  Application.Initialize;
  Application.Title := 'LiveWAII Server';

  if GInteractive then
  begin
    Application.CreateForm(TfrmServer, frmServer);
    Application.Run;
  end
  else
  begin
    frmServer := TfrmServer.Create(Application);
    frmServer.Hide;
  end;
end.

//////////////

What I'm finding is my initializations in the various units are being
performed, but one global variable is not retaining its value it is assigned
in initialization. This is very important in this application as anything
that would otherwise show up interactively is now (or should be) being
logged to a log file. My log file's path is stored in a global variable
that is assigned in initialization. The assignment is occuring, and nothing
else is touching the variable, but when I go to use it, it contains an empty
string, and I cannot write to the log file. Everything else works fine.
It's only one global variable that acts this way.. my log file path
variable.. GLogFilePath.

Listed below is the initialization in my projects main unit so you can see..
it appears everything has been done "properly". Stepping through the code
at run time shows that the calls are being made. Watching the variables
shows the values are there. Later when trying to use it, its empty...
WHY???? I am bewildered. This is the first time I've seen this
behavior.. Might Delphi be creating two pointers to the same global
variable (GLogFilePath)? That seems to be what's happening. I cannot
explain why the variable contains a null string...

Unit uServer;
...
...
initialization
  GInteractive := IsAppInteractive;
  GLogFilePath := ChangeFileExt(GetEXEPathAndName, '.log');
  GIniFilePath := ChangeFileExt(GetEXEPathAndName, '.Ini');
  gIniFile := TIniFile.Create(GIniFilePath);
  GConnectionString := gIniFile.ReadString('Alliance', 'ConnectionString',
'');
  gIniFile.Free;
finalization
end;



Relevant Pages

  • Re: Reinstalling Exchange to a new 2000 installation
    ... CLEAR OUT the database and log file directories. ... file in the directory it did not come along with the restore. ... >restore the databases and start them up on this server. ...
    (microsoft.public.exchange2000.win2000)
  • Re: Excessive amount of log files
    ... Based on that information I would say that your server is doing fine. ... 5mb attachment that will be 40Mb of transaction logs right there. ... an Exchange server will also cause transactions to be recorded. ... What we look for in high log file growth situation is large numbers of log ...
    (microsoft.public.exchange2000.general)
  • Re: Dupator.Swen.A.worm Help
    ... Why not try one of the free online virus scans? ... > I am running Small Business Server 2003. ... > on the OS partition of the machine had grown to be around ... The log file was located ...
    (microsoft.public.windows.server.sbs)
  • Re: Cant connect to the 2003 dc
    ... Mark, have you tried ... please help me verify if the server is running Citrix Metaframe. ... When the users logon to the domain, do you receive any error messages? ... Also please send me an event log file on the client computer that is ...
    (microsoft.public.windows.server.networking)
  • SecurityException during deserialization
    ... initialization is delayed after the deserialization or the server creates ... administrators account and no code access security restrictions have been ... how these can be removed or how the static initialization of classes can be ... public override string ToString() ...
    (microsoft.public.dotnet.framework.remoting)