Page 1 of 1

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

Posted: Wed Sep 20, 2017 12:32 pm
by StefanP
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

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

Posted: Thu Sep 21, 2017 9:22 am
by madshi
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';

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

Posted: Thu Sep 21, 2017 9:55 am
by StefanP
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

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

Posted: Thu Sep 21, 2017 1:04 pm
by madshi
Done.

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

Posted: Mon Sep 25, 2017 6:47 am
by StefanP
Great, thanks!