mibuso.com

Microsoft Business Solutions online community
It is currently Sun May 19, 2013 1:43 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: [Solved] How to get special folders paths?
PostPosted: Wed Oct 01, 2008 11:31 pm 
Offline

Joined: Mon Oct 23, 2006 4:18 pm
Posts: 33
Location: Zhytomyr
Country: Ukraine (ua)
For example, I need to know, what is direct path to user's "My Documents" folder (i.e. in XP ENU, usually it's %HOMEDRIVE%%HOMEPATH%\<My Documents>, in XP RUS ...\<Рабочий Стол>, and, surely, user can change it to any another path, i.e. my is "E:\AllDocs\")
How to get this?

_________________
It is hard to swim against self bloodstream... (c) Old, experienced kamikadze.


Last edited by AntidotE on Wed Oct 29, 2008 4:06 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How to get special folders paths?
PostPosted: Thu Oct 02, 2008 6:40 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Thu Oct 16, 2003 8:50 am
Posts: 12265
Location: Brno
Country: Czech Republic (cz)
You can find it through registry...
see e.g. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

_________________
Kamil Sacek
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.


Top
 Profile E-mail WWW  
 
 Post subject: Re: How to get special folders paths?
PostPosted: Thu Oct 02, 2008 7:25 am 
Offline

Joined: Mon Mar 08, 2004 2:42 pm
Posts: 3255
Location: Hannover
Country: Germany (de)
HomePath and HomeDrive is in the Key "HKEY_CURRENT_USER\Volatile Environment". The definition for, example, Start Menu is in the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders folder

If you need this also:

(in my meaning, "My Documents" is here)
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders


(and 'Shared Docs')
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

To read the Registry you can use the "Windos Scripting Host" Automation (WSHShell). There exist a function like "RegRead"

Regards

_________________
Do you make it right, it works too!


Top
 Profile  
 
 Post subject: Re: How to get special folders paths?
PostPosted: Thu Oct 02, 2008 9:05 am 
Offline

Joined: Thu Jul 17, 2003 10:52 pm
Posts: 638
Location: Capelle a/d IJssel
Country: Netherlands (nl)
You don't need the registry, below is easier:

Code: Select all
  CREATE(LautWshShell);
  LvMyDocuments := 'MyDocuments';
  LtPath := FORMAT(LautWshShell.SpecialFolders.Item(LvMyDocuments));
  CLEAR(LautWshShell);

_________________
Create dynamic Excel or Word documents, ReportX


Top
 Profile  
 
 Post subject: Re: How to get special folders paths?
PostPosted: Thu Oct 02, 2008 9:14 am 
Offline

Joined: Mon Oct 23, 2006 4:18 pm
Posts: 33
Location: Zhytomyr
Country: Ukraine (ua)
Thanks a lot, it works! =D>
and, some example to move this to Tips'n'Tricks:

Function
Code: Select all
GetFolderPath(Which : Text[20]) : Text[250]
CREATE(WSHShell);
EXIT(FORMAT(WSHShell.RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\'+Which)));
CLEAR(WSHShell);

Locals
Code: Select all
Name   DataType   Subtype   Length
WSHShell   Automation   'Windows Script Host Object Model'.WshShell   


Examples/list of possible parameter strings:
Code: Select all
MESSAGE('User Application Data Path: %1',GetFolderPath('AppData'));
MESSAGE('User Cache Path: %1',GetFolderPath('Cache'));
MESSAGE('User CD Burning Path: %1',GetFolderPath('CD Burning'));
MESSAGE('User Cookies Path: %1',GetFolderPath('Cookies'));
MESSAGE('User Desktop Path: %1',GetFolderPath('Desktop'));
MESSAGE('User Favorites Path: %1',GetFolderPath('Favorites'));
MESSAGE('User Fonts Path: %1',GetFolderPath('Fonts'));
MESSAGE('User History Path: %1',GetFolderPath('History'));
MESSAGE('User Local Application Data Path: %1',GetFolderPath('Local AppData'));
MESSAGE('User Local Settings Path: %1',GetFolderPath('Local Settings'));
MESSAGE('User My Music Path: %1',GetFolderPath('My Music'));
MESSAGE('User My Pictures Path: %1',GetFolderPath('My Pictures'));
MESSAGE('User My Video Path: %1',GetFolderPath('My Video'));
MESSAGE('User NetHood Path: %1',GetFolderPath('NetHood'));
MESSAGE('User My Documents Path: %1',GetFolderPath('Personal'));
MESSAGE('User PrintHood Path: %1',GetFolderPath('PrintHood'));
MESSAGE('User Programs Path: %1',GetFolderPath('Programs'));
MESSAGE('User Recent Path: %1',GetFolderPath('Recent'));
MESSAGE('User SendTo Path: %1',GetFolderPath('SendTo'));
MESSAGE('User Start Menu Path: %1',GetFolderPath('Start Menu'));
MESSAGE('User Startup Path: %1',GetFolderPath('Startup'));
MESSAGE('User Templates Path: %1',GetFolderPath('Templates'));

_________________
It is hard to swim against self bloodstream... (c) Old, experienced kamikadze.


Top
 Profile  
 
 Post subject: Re: How to get special folders paths?
PostPosted: Thu Oct 02, 2008 9:18 am 
Offline

Joined: Mon Oct 23, 2006 4:18 pm
Posts: 33
Location: Zhytomyr
Country: Ukraine (ua)
I was in process of writing previous post, when your appeared...
ajhvdb wrote:
You don't need the registry, below is easier:

Code: Select all
  CREATE(LautWshShell);
  LvMyDocuments := 'MyDocuments';
  LtPath := FORMAT(LautWshShell.SpecialFolders.Item(LvMyDocuments));
  CLEAR(LautWshShell);


Can you show the list of all possible parameters?

_________________
It is hard to swim against self bloodstream... (c) Old, experienced kamikadze.


Top
 Profile  
 
 Post subject: Re: How to get special folders paths?
PostPosted: Thu Oct 02, 2008 10:30 am 
Offline

Joined: Mon Oct 23, 2006 4:18 pm
Posts: 33
Location: Zhytomyr
Country: Ukraine (ua)
Ah, btw, this all concerns XP, what about Vista? Is there the same regpath? I haven't vista here and can't look at...

_________________
It is hard to swim against self bloodstream... (c) Old, experienced kamikadze.


Top
 Profile  
 
 Post subject: Re: How to get special folders paths?
PostPosted: Thu Oct 02, 2008 3:19 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Thu Oct 16, 2003 8:50 am
Posts: 12265
Location: Brno
Country: Czech Republic (cz)
The path I wrote is from Vista, it means same path, but may be more keys... there is backward-compatibility...

_________________
Kamil Sacek
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.


Top
 Profile E-mail WWW  
 
 Post subject: Re: How to get special folders paths?
PostPosted: Thu Oct 02, 2008 7:22 pm 
Offline
Moderator
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Wed Jul 02, 2003 10:13 am
Posts: 7493
Location: Milan
Country: Italy (it)
[Topic moved from 'NAV/Navision' forum to 'NAV Tips & Tricks' forum]

_________________
Regards,Alain Krikilion
Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title! || Read Forum Rules before making a posting


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: