Page 1 of 1

Errsysw enhancement

Posted: Mon Dec 22, 2008 4:43 pm
by StefanHaupt
Hello to all,

the last days, I made some tests about the compatibility of fwh applications and vista and I found, the error logfile could not be written, if I follow the programming rules of vista (and XP also ! ).

The point is, that a normal user (without admin privilegs) is not allowed to write in the program directory. If we follow the programing rules, data has to be separated from the program. The applications has to be installed in the program directory and the data either in the homedir of the user or in the alluser homedir.

I made some small changes in errsysw.prg to take account of these rules.

With the new function SetErrorLog (cLogfile) you can decide, where the error.log will be written, default is the homedir of allusers.

Code: Select all

external _fwGenError   // Link FiveWin generic Error Objects Generator

STATIC cLog    // NEW Stefan Haupt 20.12.2008

/*************
*   ErrorSys()
*
*   Note:  automatically executes at startup
*/
proc ErrorSys()
  SetErrorLog ()                  // NEW Stefan Haupt 20.12.2008
  ErrorBlock( { | e | ErrorDialog( e ) } )
return

proc ErrorLink()
return

//---------------------------------------------------
// Set errorlog file
// Stefan Haupt 20.12.2008
//---------------------------------------------------
PROCEDURE SetErrorLog (cLogFile)
  DEFAULT cLogFile := IIF (IsWinVista(), GetEnv("AllUsersProfile")+"\Error.log",;
                                        GetEnv("AllUsersProfile")+"\Anwendungsdaten\Temp\Error.log")
  cLog := cLogFile
RETURN

//---------------------------------------------------
// Get errorlog file
// Stefan Haupt 20.12.2008
//---------------------------------------------------
FUNCTION GetErrorLog ()
  RETURN (cLog)

.....
.....
// Generates a file with an Error Log

   BEGIN SEQUENCE
      oOldError = ErrorBlock( { || DoBreak() } )
      //MemoWrit( "Error.log", cErrorLog )
       MemoWrit( cLog, cErrorLog )            // NEW Stefan Haupt 20.12.2008
   END SEQUENCE
   ErrorBlock( oOldError )



Posted: Tue Dec 23, 2008 8:24 am
by Antonio Linares
Stefan,

Thanks! :-)

How could we translate Anwendungsdaten ? Data ?

Posted: Tue Dec 23, 2008 11:01 am
by Detlef Hoefner
Antonio,

Anwendungsdaten means 'application data' or 'program files'.

Regards,
Detlef

Posted: Tue Dec 23, 2008 11:13 am
by Antonio Linares
Detlef,

Windows german uses "Anwendungsdaten" ?

If it is a different word for each country then we may need to find a way to locate such name in each language.

Posted: Tue Dec 23, 2008 11:26 am
by Detlef Hoefner
Antonio,
Windows german uses "Anwendungsdaten" ?
Yes, it's used by Windows.
Here a picture

Image

This folder normally is created by the system.

Regards,
Detlef

Posted: Tue Dec 23, 2008 11:47 am
by Jack
I suppose it is Application data

Posted: Tue Dec 23, 2008 12:12 pm
by StefanHaupt
Antonio,

in english versions of XP "Application Data" is correct ("Program Files" is the directory where the applications are installed), in other languages it may vary.

The name can be found in the registry

key: [HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoamMUICache]
Entry: @shell32.dll,-21765

Posted: Tue Dec 23, 2008 8:29 pm
by Ken Wantz
Antonio,

I looked in my copy of XP Pro and @shell32.dl,-21765 was not to be found. I am suspicious any time I find an entry that has MUI and/or cache in the description.

I did find, however, Application Data at the following address in my English copy of XP Pro and Vista:
  • [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]
In XP Pro, listed under AppData is %USERPROFILE%\Application Data but in Vista the same key lists it as %USERPROFILE%\AppData\Roaming.

Another entry in the samegroup is Local AppData. In XP Pro it is the same as before, %USERPROFILE%\Application Data but in Vista it is listed as %USERPROFILE%\AppData\Local.

I think this is a preferred place to look. Maybe others using other languages can confirm if this indeed is the place to retrieve the folder information from.

Ken

Posted: Wed Dec 24, 2008 1:05 pm
by StefanHaupt
Ken,

all the entries you mentioned are only for the current user, not for the the allusers account.

In the german version of XP the entry @shell32.dl,-21765 exists, but it may be that this entry is only for the translation in other languages, so it may not exist in the original english version, because you do not need it there.

It would be interesting if other users of localized version could check if this entry does exist and tell the results.

Posted: Wed Dec 24, 2008 4:08 pm
by Ken Wantz
Stefan,

You are right, but I followed your lead. It might be only for a specific user, I am not aware of a Windows version that, after installation, that can run multiple default languages. While I might be barking up the wrong tree, whatever language is selected during the install would become the default language for all users.

In any case it makes sense to save the error info for each specific user. That way, if several users use the same application on the same machine, then the error might indicate all users are getting the same error or it is unique to only a specific user.

That aside, if you are looking for a more general area to save the error information, check the following key;
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
In XP Pro:

Code: Select all

"Common AppData"="C:\\Documents and Settings\\All Users\\Application Data"
And in Vista:

Code: Select all

"Common AppData"="C:\\ProgramData"
I guess it is whatever works best for the user/programmer as to which location to use to save the information.

Ken

Posted: Wed Dec 24, 2008 8:32 pm
by James Bott
Ken,

>In any case it makes sense to save the error info for each specific user. That way, if several users use the same application on the same machine, then the error might indicate all users are getting the same error or it is unique to only a specific user.

The downside of creating separate error logs for each user is that you then have to look on each local machine to find all the error logs.

It is easy enough to modify the program to save the user name with the error message and then save all the errors to the same error log.

Regards,
James

Posted: Fri Dec 26, 2008 11:04 am
by demont frank
I agree , i have as code :

Code: Select all

#ifndef TEST
cErFile := "ERRORS\Er" + DTOS(DATE()) + "." + CharOnly("0123456789",Time()) + ".log"
# else
cErFile := "ERRORS\Error"  + ".log"
# endif
The program dir must have subdir ERROR , in the errorfile i have the name from the user
James Bott wrote:Ken,

>In any case it makes sense to save the error info for each specific user. That way, if several users use the same application on the same machine, then the error might indicate all users are getting the same error or it is unique to only a specific user.

The downside of creating separate error logs for each user is that you then have to look on each local machine to find all the error logs.

It is easy enough to modify the program to save the user name with the error message and then save all the errors to the same error log.

Regards,
James