Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC8.0 Win32
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 6-Apr-11 4:07am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.]
  Permalink  
Comments
SAKryukov at 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 at 6-Apr-11 22:09pm
   
No, SHGetFolderPath works fine on Win7. It's the MS-recommended alternative that does not work prior to Vista.
SAKryukov at 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 at 7-Apr-11 0:21am
   
It's sad, pathetic, idiotic. I run out of words to describe.
SAKryukov at 7-Apr-11 0:37am
   
Must die.
Jayant Narayan Dash at 7-Apr-11 1:32am
   
Thanks to all of you for your valuable reply...

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

  Print Answers RSS
0 OriginalGriff 475
1 Maciej Los 349
2 Richard MacCutchan 220
3 BillWoodruff 219
4 Mathew Soji 160
0 OriginalGriff 8,759
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,269
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411028.1 | Last Updated 6 Apr 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100