Getting local My Documents folder path

Posted by smsrecv on Stack Overflow See other posts from Stack Overflow or by smsrecv
Published on 2012-11-03T22:06:54Z Indexed on 2012/11/03 23:01 UTC
Read the original article Hit count: 170

Filed under:
|

In my C++/WinAPI application I get the My Documents folder path using this code:

wchar_t path[MAX_PATH];
SHGetFolderPathW(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,path);

One of the users runs my program on a pc connected to his corporate network. He has the My Documents folder on a network. So my code returns something like \paq\user.name$\My Documents Though he says he has a local copy of My Documents. The problem is that when he 'swaps VPN', the online My Documents becomes unavailable and my program crashes with the system error code 64 "The specified network name is no longer available" ( it tries to write to the file opened in the online my docs folder).

How can I always get the local My Documents folder path using C++/WinAPI?

© Stack Overflow or respective owner

Related posts about Windows

Related posts about winapi