FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Errsysw enhancement
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Errsysw enhancement
Posted: Mon Dec 22, 2008 04:43 PM
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.

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 )
kind regards

Stefan
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Errsysw enhancement
Posted: Tue Dec 23, 2008 08:24 AM

Stefan,

Thanks! :-)

How could we translate Anwendungsdaten ? Data ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
Errsysw enhancement
Posted: Tue Dec 23, 2008 11:01 AM

Antonio,

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

Regards,
Detlef

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Errsysw enhancement
Posted: Tue Dec 23, 2008 11:13 AM

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.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
Errsysw enhancement
Posted: Tue Dec 23, 2008 11:26 AM
Antonio,

Windows german uses "Anwendungsdaten" ?


Yes, it's used by Windows.
Here a picture



This folder normally is created by the system.

Regards,
Detlef
Posts: 300
Joined: Wed Jul 11, 2007 11:06 AM
Errsysw enhancement
Posted: Tue Dec 23, 2008 11:47 AM

I suppose it is Application data

Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Errsysw enhancement
Posted: Tue Dec 23, 2008 12:12 PM

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

kind regards

Stefan
Posts: 45
Joined: Wed Nov 29, 2006 07:48 PM
Errsysw enhancement
Posted: Tue Dec 23, 2008 08:29 PM
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][/list:u]
    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
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Errsysw enhancement
Posted: Wed Dec 24, 2008 01:05 PM

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.

kind regards

Stefan
Posts: 45
Joined: Wed Nov 29, 2006 07:48 PM
Errsysw enhancement
Posted: Wed Dec 24, 2008 04:08 PM
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[/list:u]
    In XP Pro:
    "Common AppData"="C:\\Documents and Settings\\All Users\\Application Data"


    And in Vista:
    "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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Errsysw enhancement
Posted: Wed Dec 24, 2008 08:32 PM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 167
Joined: Thu Mar 22, 2007 11:24 AM
Errsysw enhancement
Posted: Fri Dec 26, 2008 11:04 AM
I agree , i have as code :
#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

Continue the discussion