Getting the 'My Documents' folder for all users

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


Description

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

Code Example

Name "Get All Users My Documents Folder"
OutFile "Example.exe"
 
Page instfiles
 
ShowInstDetails show
 
Section
 
  ;code by JeronimoColon
  SetPluginUnload alwaysoff
  StrCpy $1 ""
  IntOp $2 0x002e + # CSIDL_COMMON_DOCUMENTS (0x002e)
 
  ;(code by JasonFriday13) 
  ;Can also use StrCpy here (uncomment line below, comment line above).
  ;StrCpy $2 "0x002e" ;(end code by JasonFriday13)
 
  System::Call 'shell32::SHGetSpecialFolderPath(i $HWNDPARENT, t .r1, i r2, i r3) i .r4'
 
  SetPluginUnload manual
  System::Free 0
 
  DetailPrint "API Call Results: $1"
  ;end of code
 
SectionEnd