Getting the 'My Documents' folder for all users

From NSIS Wiki
Jump to navigationJump to search
Author: JasonFriday13 (talk, contrib)


Description

This example gets the folder path to the all users 'My Documents' folder. This code example was written by JeronimoColon as a possible solution to a problem in this thread. Therefore is now documented here in the wiki.

Usage

Call GetSharedDocPath
Pop $0

The Function

;This code was originally written by JeronimoColon, but has 
;been stripped down for use as a function here.
 
Function GetSharedDocPath
  Push $1
  Push $2
  Push $3
  Push $4  
 
  StrCpy $1 ""
  StrCpy $2 "0x002e" # CSIDL_COMMON_DOCUMENTS (0x002e)
  StrCpy $3 ""
  StrCpy $4 ""
 
  System::Call 'shell32::SHGetSpecialFolderPath(i $HWNDPARENT, t .r1, i r2, i r3) i .r4'
 
  Pop $4
  Pop $3
  Pop $2
  Exch $1
FunctionEnd