I want to copy some document templates to the user's "My Documents" folder at setup time. In my C++ program I need to read from that folder. Though the folder mostly is located at "%userprofile%\My Documents" there is a chance that the user moved it to some other path.
I found out that the path of the folder was stored in registry at "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal". I easily could read that value in C++.
I also found a VB code snippet by googling that retrieves the folder name by
from win32com.shell import shell
df = shell.SHGetDesktopFolder()
pidl = df.ParseDisplayName(0, None,
mydocs = shell.SHGetPathFromIDList(pidl)
I am weak in VB but I think I would be able to convert the snippet to C++.
I have a few questions related to that:
1. Are these solutions equivalent and valid? Means, do they always retrieve a valid path name?
2. Isn't there an easier solution, e. g. using a predefined name like %mydocs%?
3. If not, does anyone know another solution that can be used in a batch file?
Thanks in advance