Search code examples
mapped-drive

C++ Program cannot see mapped drives


I am coding an unmanaged C++ console application on Windows 7 using Visual Studio 2010. I ran into an issue where files on my local computer or a network location work fine, but my code can't see anything on a mapped drive. I can simply this issue to a program that is the following 2 lines:

const WCHAR * libPath = _T("L:\MyFiles\myfile.txt"); DWORD fa = GetFileAttributes(libPath);

Where fa comes back as 0xFFFFFFFF, L is a mapped drive, and L:\MyFiles\myfile.txt is a valid text file.

How do I access mapped drives?


Solution

  • This is a problem with Visual Studio. "Start without debugging" is NOT the same as running from explorer on Windows 7. The program works fine started from Windows Explorer. This is due to different UAC rights.