Hi. How to define path to My Document (users have diferent)

randrewsrandrews Member Posts: 135
For example:
One User1 have
C:\Documents and Settings\User1\My Documents\
Another User2:
C:\Documents and Settings\User2\My Documents\

How to know real path on client machine who run report?

Thanks

Comments

  • ArhontisArhontis Member Posts: 667
    Hi,

    Look at the
    http://www.mibuso.com/forum/viewtopic.p ... light=path

    that goes thru the environemt parameters, but you must set the my documents parameter to the system first.
    or you could look at the:

    http://www.mibuso.com/forum/viewtopic.p ... light=path

    to use with registry key:

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

    in the personal value that keeps the location of my documents.
  • randrewsrandrews Member Posts: 135
    Info about reading register helps me
    Thank you
  • RobertMoRobertMo Member Posts: 484
    The simplest way would be:
    MyDocPath := ENVIRON('USERPROFILE') + '\My Documents';
    
    since USERPROFILE returns: C:\Documents and Settings\user

    Beware that OS langauge may affect 'My Documents' is also translated. You can define multilanguage TextConstant.

    The most accurate would be to read registry.
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • fbfb Member Posts: 246
    Lots of options here... Here's another one:
    PROCEDURE GetSpecialFolder(FolderName : Text[20]) : Text[250];
    VAR
      wshShell : Automation 'Windows Scripting Host.wshShell';
      vntFolderName : Variant;
      vntFolderPath : Variant;
    BEGIN
      CREATE(wshShell);
      vntFolderName := FolderName;
      vntFolderPath := wshShell.SpecialFolders.Item(vntFolderName);
      CLEAR(wshShell);
      IF vntFolderPath.ISTEXT THEN
        EXIT(FORMAT(vntFolderPath));
    END;
    
    Call this with 'MyDocuments', or one of the other special folder names in this list:
    http://msdn.microsoft.com/library/defau ... olders.asp
  • randrewsrandrews Member Posts: 135
    to RobertMo
    Unfortanitly, in our company OS Windows English and Windows Russian. 'My Documents' in two languages (on diferent system). So write directly 'My Documents' isn't work in russian versions.

    I did it with Automation 'Windows Scripting Host.wshShell'

    Thanks to all
Sign In or Register to comment.