Initialization problems with hidden application
From: Perry Way (no.delphipro.spam_at_no.spam.earthlink.net)
Date: 01/13/04
- Next message: Didier Cabalé: "public property in a TCustomEdit descendant"
- Previous message: Brett Watters: "Re: Service App Problem"
- Next in thread: Kelly Leahy: "Re: Initialization problems with hidden application"
- Reply: Kelly Leahy: "Re: Initialization problems with hidden application"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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;
- Next message: Didier Cabalé: "public property in a TCustomEdit descendant"
- Previous message: Brett Watters: "Re: Service App Problem"
- Next in thread: Kelly Leahy: "Re: Initialization problems with hidden application"
- Reply: Kelly Leahy: "Re: Initialization problems with hidden application"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|