Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I need to get the path of shared/public document in XP, vista and windows7.
please give me a code snapshot for this.

i am writing code in windows XP and the same code i want to run in xp, vista and windows7

Thanks in advance.
Posted

1 solution

Call SHGetFolderPath() with the CSIDL CSIDL_COMMON_DOCUMENTS.

See here for more CSIDLs: http://msdn.microsoft.com/en-us/library/bb762494%28v=VS.85%29.aspx[^].

[Note: ignore the nonsense about SHGetFolderPath() being deprecated. If you follow the advice in MSDN, your app won't work on XP or earlier systems.]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Apr-11 18:56pm    
Correct (especially with the reference to the CLSID). My 5.
Obsolete SHGetFolderPath is a problem. What, is it invalid for Windows 7? Similar .NET GetFolderPath does work correctly on all systems I know...
--SA
Hans Dietrich 6-Apr-11 22:09pm    
No, SHGetFolderPath works fine on Win7. It's the MS-recommended alternative that does not work prior to Vista.
Sergey Alexandrovich Kryukov 7-Apr-11 0:00am    
Thank you for your answer, Hans. That's what I say: would require different code for XP and Windows 7. It's easy to implement but... just sad :=<.
--SA
Hans Dietrich 7-Apr-11 0:21am    
It's sad, pathetic, idiotic. I run out of words to describe.
Sergey Alexandrovich Kryukov 7-Apr-11 0:37am    
Must die.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900