[Win32utils-devel] SHGetFolderPath and stuff

Zach Dennis zdennis at mktec.com
Mon Feb 7 12:05:07 EST 2005


Berger, Daniel wrote:
> Hi Zach
>  
> 
>>here's the snippet I use to get the My Documents path on Windows Xp
>>
>>proc = GetProcAddress( hDll , "SHGetSpecialFolderPathA" ); 
>>//...snip.. (proc)( NULL, cPath, PATH_MYDOCUMENTS, FALSE );
> 
> 
> The docs say that SHGetSpecialFolderPath has been superseded by
> SHGetFolderPath on Win2k and later, though the docs say that Windows NT
> 4 SP 4 and later also support it.
> 
> Where did you get "PATH_MYDOCUMENTS"?  It's not a CSIDL, but if it's
> something we can rely on, I can write the code in such a way as to fall
> back on PATH_ macros if the CSIDL_ macro is not supported.

oops... PATH_MYDOCUMENTS is the same value as the CSIDL_MYDOCUMENTS 
value 0x05

> 
> 
> SHGetSpecialFolderPath is the (older) standard function.
> SHGetSpecialFolderPathA is the ANSI version while
> SHGetSpecialFolderPathU is the Unicode version.  You usually don't call
> the 'A' or 'U' versions directly.  You use SHGetSpecialFolderPath, and
> Windows uses either the 'A' or 'U' version behind the scenes, depending
> on the value of the UNICODE macro.
> 
> At least, that's my understanding.

That sounds about right. The only experience I have with retrieving this 
information is in testing of a Windows 2000 and Windows XP Professional 
edition OS's for a java-based application I wrote. If I remember 
correctly SHGetSpecialFolder path was segfaulting my extension, but 
SHGetSpecialFolderA worked.

It was a while ago when I wrote java extension and I can check it out 
again if need be, but if SHGetFolderPath is the correct way to go then 
please go that route. I'm just posting  my experience in case it 
provides any help. I don't believe I tried SHGetFolderPath back in the day.

Zach



More information about the win32utils-devel mailing list