Save bug report under C:\users\<user>\appdata\local\

delphi package - automated exception handling

Save bug report under C:\users\<user>\appdata\local\

Postby StefanP » Wed Sep 20, 2017 12:32 pm

See subject.

I tried
%userappdata%\mycompany\myproduct\bug_report.txt
Report is saved in
C:\users\<user>\appdata\roaming\mycompany\myproduct\bug_report.txt

Also tried
%localappdata%
Does not work, it is not decoded.
Report is saved in
<DirOfExe>\%localappdata%\mycompany\myproduct\bug_report.txt
In the line above %localappdata% is a real directory, not a placeholder.

This hack works (tested on Windows 7 only):
%userappdata%\..\local\mycompany\myproduct\bug_report.txt

What is the correct way?

TIA
Stefan
StefanP
 
Posts: 3
Joined: Wed Sep 20, 2017 12:18 pm

Re: Save bug report under C:\users\<user>\appdata\local\

Postby madshi » Thu Sep 21, 2017 9:22 am

madExcept interprets those vars as follows:

Code: Select all
  ReplaceTextW(str, '%desktop%', GetSpecialFolderW(CSIDL_DESKTOPDIRECTORY, false));
  if PosTextW('%userappdata%', str) > 0 then
    ReplaceTextW(str, '%userappdata%', GetSpecialFolderW(CSIDL_APPDATA, false));
  if PosTextW('%commonappdata%', str) > 0 then
    ReplaceTextW(str, '%commonappdata%', GetSpecialFolderW(CSIDL_COMMON_APPDATA, false));

I'm not sure why it results in such weird paths in your case. In any case, you can specify any path you want at runtime, by doing this:

Code: Select all
uses ..., madExcept;

initialization
  MESettings().BugReportFile := 'c:\whateverPathYouLike\bugreport.mbr';
madshi
Site Admin
 
Posts: 9460
Joined: Sun Mar 21, 2004 5:25 pm

Re: Save bug report under C:\users\<user>\appdata\local\

Postby StefanP » Thu Sep 21, 2017 9:55 am

Mathias,

can you add this:

if PosTextW('%localappdata%', str) > 0 then
ReplaceTextW(str, '%localappdata%', GetSpecialFolderW(CSIDL_LOCAL_APPDATA, false));

That's what I need ;-)

For the time being I will use the runtime approach...

All the best
Stefan
StefanP
 
Posts: 3
Joined: Wed Sep 20, 2017 12:18 pm

Re: Save bug report under C:\users\<user>\appdata\local\

Postby madshi » Thu Sep 21, 2017 1:04 pm

Done.
madshi
Site Admin
 
Posts: 9460
Joined: Sun Mar 21, 2004 5:25 pm

Re: Save bug report under C:\users\<user>\appdata\local\

Postby StefanP » Mon Sep 25, 2017 6:47 am

Great, thanks!
StefanP
 
Posts: 3
Joined: Wed Sep 20, 2017 12:18 pm


Return to madExcept

Who is online

Users browsing this forum: No registered users and 3 guests

cron