Thanks for answers to everybody.
What I wanted to do, was to be able to get a constant string (the
Application.Title) from any unit of my application (and maybe also from
external units/VCLs) and to use this constant (the name of the
application) to create a folder in 'application data' where to write the
INI files.
For example:
function SaveIniFile( s: string ): string;
begin
Result:= GetAppDataFolder+ s+ 'MyINI.ini';
end;
Usage:
Application.Title= 'Bitmap Resampler';
GetUserPath(Application.Title);
The result should be something like:
c:\Documents and Settings\USER_NAME\Application
Data\Bitmap Resampler\MyINI.ini
Anyway I abandoned the idea and I used a simple constant like
const AppTitle= 'Bitmap Resampler' that solved the problem.
Anyway, it is still strange that reading/accessing the
'Application.Title' inside the DPR file (at design time) will make the
project impossible to load in IDE!
________________________________________________________
Ross Levis wrote:
> I regularly change the Application Title in the main form and it has never
> crashed. I use it to display progress of some processing while the app is
> minimized.
>
> Ross.
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Barton Bresnik
> Sent: Friday, 3 August 2007 13:55
> To: [email protected]
> Subject: Re: crashes when I try to use Application.Title
>
> This issue may trace back to MS Windows API: memory must be allocated for
> the title. If you set the title at design time, Delphi is usually
> intelligent enough to pre-allocate the memory. At run time, setting it equal
> to a string value will crash an app, because strings are lifetime-managed:
> once it goes out of scope (e.g. at the end of a procedure), the title points
> to an invalid location.
>
> Work-arounds: global strings that last the lifetime of the app; allocate
> memory for a buffer; allocate an array of char...
>
> Bart
>
> _______________________________________________
> Delphi mailing list -> [email protected]
> http://www.elists.org/mailman/listinfo/delphi
>
>
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi