PDA

View Full Version : Alternative path for .elf file


JohaViss
20-Oct-2005, 10:35 AM
Hello,

We have an application that is capable of running from a CD-ROM.
When there is an error there is no .elf file written because you can't write on a CD-ROM.
Is it possible to write the .elf file to the directory of the app when it's allowed to write and to another dir when it's not allowed to write. :)


Second question: :cool:
Is it possible to specify the output dir with a short notation?
We can't be sure what the name of a system dir is ('WINDOWS' or 'WINNT')
We would like to use a style like this {win} to indicate the Windows dir and {sys} for a SYSTEM32 directory.

Johan Visser

Florent Guiliani
20-Oct-2005, 02:39 PM
JohaViss a écrit :
> Hello,
>
> We have an application that is capable of running from a CD-ROM.
> When there is an error there is no .elf file written because you can't
> write on a CD-ROM.
> Is it possible to write the .elf file to the directory of the app when
> it's allowed to write and to another dir when it's not allowed to
> write. :)
I think you have to write code to testing this and then set the choosen
directory

>
>
> Second question: :cool:
> Is it possible to specify the output dir with a short notation?
> We can't be sure what the name of a system dir is ('WINDOWS' or
> 'WINNT')
> We would like to use a style like this {win} to indicate the Windows
> dir and {sys} for a SYSTEM32 directory.

You can ask for the registry or environment variable to get the system
directory or temp directory or others...

type set in a command prompt.
exemple:

TEMP=C:\DOCUME~1\perinfo\LOCALS~1\Temp
TMP=C:\DOCUME~1\perinfo\LOCALS~1\Temp
HOMEPATH=\Documents and Settings\perinfo
SystemDrive=C:
SystemRoot=C:\WINDOWS
windir=C:\WINDOWS
....

admin
20-Oct-2005, 05:48 PM
Florent Guiliani wrote:
> JohaViss a écrit :
>
>> Hello,
>>
>> We have an application that is capable of running from a CD-ROM.
>> When there is an error there is no .elf file written because you can't
>> write on a CD-ROM.
>> Is it possible to write the .elf file to the directory of the app when
>> it's allowed to write and to another dir when it's not allowed to
>> write. :)
>
> I think you have to write code to testing this and then set the choosen
> directory

Yes, it's so! :)

>> Second question: :cool: Is it possible to specify the output dir with
>> a short notation?
>> We can't be sure what the name of a system dir is ('WINDOWS' or
>> 'WINNT')
>> We would like to use a style like this {win} to indicate the Windows
>> dir and {sys} for a SYSTEM32 directory.
>
>
> You can ask for the registry or environment variable to get the system
> directory or temp directory or others...
>
> type set in a command prompt.
> exemple:
>
> TEMP=C:\DOCUME~1\perinfo\LOCALS~1\Temp
> TMP=C:\DOCUME~1\perinfo\LOCALS~1\Temp
> HOMEPATH=\Documents and Settings\perinfo
> SystemDrive=C:
> SystemRoot=C:\WINDOWS
> windir=C:\WINDOWS
> ...

Or use the GetWindowsDirectory/GetSystemDirectory Windows API! :)

--
Best regards...

Fabio Dell'Aria.
----------------
http://www.eurekalog.com
Catch every BUG showing line n.

Erez Amir
24-Oct-2005, 07:03 AM
NOTE: The problem is not only with CD-Roms. You should design your
application to run as non-administrator user. (For example, at home, all my
kids have their accounts as users and I'm the admin with a password, they
use finger-print reader to log-in. cooool)
non-admin users cannot write to "\program files", where your app is usually
installed to. So I use this piece of code to redirect the ELF file to the
desired path under the user profile


// Direct the log to a reasonable path
procedure MyNotify(ExcRecord: TEurekaExceptionRecord; var Handled: Boolean);
Function Env(Name:String):String;
Var Res: Array[0..255] of char;
begin
Res := #0;
GetEnvironmentVariable(PCHAR(Name), Res, sizeof(Res));
Result := Res;
end;
Var Path : String;
begin
Path := Env('UserProfile');
if Path = '' then Path := '\'; // On Win9x, %UserProfile% is not defined
ExcRecord.CurrentModuleOptions.OutputPath := Path
end;

// this goes inside the project's (DPR) main begin-end block
...
ExceptionNotify := MyNotify;
...


Hope this helps
- Erez

"admin" <support@eurekalog.com> wrote in message
news:dj8hn9$gf3$1@plesk.eurekalog.com...
> Florent Guiliani wrote:
>> JohaViss a écrit :
>>
>>> Hello,
>>>
>>> We have an application that is capable of running from a CD-ROM.
>>> When there is an error there is no .elf file written because you can't
>>> write on a CD-ROM.
>>> Is it possible to write the .elf file to the directory of the app when
>>> it's allowed to write and to another dir when it's not allowed to
>>> write. :)
>>
>> I think you have to write code to testing this and then set the choosen
>> directory
>
> Yes, it's so! :)
>
>>> Second question: :cool: Is it possible to specify the output dir with a
>>> short notation?
>>> We can't be sure what the name of a system dir is ('WINDOWS' or
>>> 'WINNT')
>>> We would like to use a style like this {win} to indicate the Windows
>>> dir and {sys} for a SYSTEM32 directory.
>>
>>
>> You can ask for the registry or environment variable to get the system
>> directory or temp directory or others...
>>
>> type set in a command prompt.
>> exemple:
>>
>> TEMP=C:\DOCUME~1\perinfo\LOCALS~1\Temp
>> TMP=C:\DOCUME~1\perinfo\LOCALS~1\Temp
>> HOMEPATH=\Documents and Settings\perinfo
>> SystemDrive=C:
>> SystemRoot=C:\WINDOWS
>> windir=C:\WINDOWS
>> ...
>
> Or use the GetWindowsDirectory/GetSystemDirectory Windows API! :)
>
> --
> Best regards...
>
> Fabio Dell'Aria.
> ----------------
> http://www.eurekalog.com
> Catch every BUG showing line n.

admin
24-Oct-2005, 11:39 AM
Erez Amir wrote:
> NOTE: The problem is not only with CD-Roms. You should design your
> application to run as non-administrator user. (For example, at home, all my
> kids have their accounts as users and I'm the admin with a password, they
> use finger-print reader to log-in. cooool)
> non-admin users cannot write to "\program files", where your app is usually
> installed to. So I use this piece of code to redirect the ELF file to the
> desired path under the user profile
>
>
> // Direct the log to a reasonable path
> procedure MyNotify(ExcRecord: TEurekaExceptionRecord; var Handled: Boolean);
> Function Env(Name:String):String;
> Var Res: Array[0..255] of char;
> begin
> Res := #0;
> GetEnvironmentVariable(PCHAR(Name), Res, sizeof(Res));
> Result := Res;
> end;
> Var Path : String;
> begin
> Path := Env('UserProfile');
> if Path = '' then Path := '\'; // On Win9x, %UserProfile% is not defined
> ExcRecord.CurrentModuleOptions.OutputPath := Path
> end;
>
> [...]
>
> Hope this helps
> - Erez

Perfect! :)

Using your suggestion, I have created a new EurekaLog 5.0.5 RC 2.

This new version check if the file to write is writable and if it isn't
move it to the %UserProfile%\EurekaLog folder.

Also for the Log-File and for the EurekaLog.ini file (used to store the
Exception Dialog state).

Can you test it please?

> [...]

--
Best regards...

Fabio Dell'Aria.
----------------
http://www.eurekalog.com
Catch every BUG showing line n.

JohaViss
25-Oct-2005, 08:49 PM
Hello,

I have tested the solution you have build. :cool:
It works perfect.
Finally I don't have to worry that I lose the error messages and have to ask the users what was wrong.

Thank you very much. :)

When can we expect the final version?

Greetings Johan Visser

admin
26-Oct-2005, 08:19 AM
Hi,

JohaViss wrote:
> Hello,
>
> I have tested the solution you have build. :cool:
> It works perfect.
> Finally I don't have to worry that I lose the error messages and have
> to ask the users what was wrong.
>
> Thank you very much. :)
>
> When can we expect the final version?
>
> Greetings Johan Visser

Into the next month (start of next month)! :)

--
Best regards...

Fabio Dell'Aria.
----------------
http://www.eurekalog.com
Catch every BUG showing line n.