title: CreateFile failed with ACCESS_DENIED for network drive on Windows 7
body: <p>i'm having issue with the windows CreateFile function for network drive on Windows 7 (<strong>it works perfectly on XP</strong>). </p>
  
  <p>before calling Createfile, i mount the network drive  :</p>
  
  <pre><code>nr.dwType = RESOURCETYPE_DISK;
  nr.lpLocalName = NULL;// to let windows auto choose the local letter
  nr.lpRemoteName = strTemp.GetBuffer(); // example: \\myhost\mySharedFolder
  nr.lpProvider = NULL;
  
  TCHAR AccessName [MAX_PATH];            
  DWORD dwSize = sizeof(AccessName);
  ZeroMemory(AccessName,dwSize);
  dwResult = WNetUseConnection(NULL
          ,&amp;nr
          ,(LPSTR) NULL
          ,(LPSTR) NULL
          ,CONNECT_REDIRECT
          ,AccessName
          ,&amp;dwSize
          ,&amp;dwRet);
  </code></pre>
  
  <p>this works well. I see the mounted drive in Win7 explorer, it's shared with total control from the host side, i can create, edit, delete files ...no issue here.</p>
  
  <p>Then i want to get devices information using CreateFiles :</p>
  
  <pre><code>TCHAR szVolumeName[8];
  sprintf(szVolumeName, "\\\\.\\%s", szDrive);  //for example \\.\z:
  HANDLE hDevice = CreateFile(szVolumeName,
              0/*GENERIC_READ | GENERIC_WRITE*/,
              FILE_SHARE_READ | FILE_SHARE_WRITE,
              NULL,
              OPEN_EXISTING,
              0,
              NULL);
  </code></pre>
  
  <p>Note the path formating '\\.\driveLetter: '  (according to <a href="http://support.microsoft.com/kb/100027/en-us" rel="nofollow noreferrer">this article</a>).   I also read this <a href="https://stackoverflow.com/questions/9587756/why-is-createfile-failing-to-open-a-file-across-a-network-share">post</a> but it everything fails harder if i format the string like " z:" or "z:\" </p>
  
  <p>Also note the '0' for the acces right mask, which allow, according to <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx" rel="nofollow noreferrer">msdn documentation</a>:</p>
  
  <blockquote>
    <p>If this parameter is zero, the application can query certain metadata such as file, directory, or device attributes without accessing that file or device, even if GENERIC_READ access would have been denied.</p>
  </blockquote>
  
  <p>And despite all this, it fails with a <strong>getLastError() = 5</strong>  on Win7 (as mentioned earlier, it works on XP)
  Whereas it works for local drives (even removable devices)</p>
  
  <p>I have the same behabiour running the app under a standard user account or an admin account and "runnin as admin" thingy</p>
  
  <p>So, question :  Is this normal behaviour, what could I do about it ? Why does it works for local drive even when run as standard user ?</p>