Question

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?

Was it helpful?

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.

OTHER TIPS

One possibility is that your application is running in elevated mode (ie. with Run as administrator selected). The problem is discussed in greater detail here.

The solution is to use net use to mount the drive or merge this into your registry:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLinkedConnections"=dword:00000001

Note that a reboot is required after making the above change.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top