title: How do I create a file in VC++ 6.0 when UAC is on?
body: <p>How do I create a file in C++ when UAC is on, but with out running as administrator?</p>
  
  <p>I'm trying to create a text file in the following path: "C:\Programdata\Desktop" in VC++ 6.0 when Vista's UAC is on. However, <code>Createfile(...)</code> failed with 'permission denied'.</p>
  
  <p>When I run the sample application with "run as administrator" it works. But my sample application should not "run as administrator".</p>
  
  <p>Is there any API to give permission to the above path, when UAC is on?</p>
  
  <p>sample code:
  const nSize = 100;
  CStdioFile  file;
  CFileException obFileExp;
  CString csFilePath(_T("C:\ProgramData\Desktop\sample.txt"));</p>
  
  <pre><code>if (!file.Open( csFilePath , CFile::modeCreate | CFile::modeWrite ,&amp;obFileExp ) )
  {
      // opening of file failed  
      TCHAR szErr[nSize];
      obFileExp.GetErrorMessage(szErr,nSize);
      AfxMessageBox(szErr);
      return ;
  }  
  
  file.WriteString( "welcome" );
  
  file.Close( );
  </code></pre>
  
  <hr>
  
  <p>NOTE: UAC should ON and VC++ 6.0 should NOT run as administrator</p>