title: create a folder and files in c:\program files\myApp\data in windows 7
body: <p>I have an old c++ application that needs to be modified to work with windows 7.
  Problem is in creating a new folder and saving a file in that folder. This folder should be created in </p>
  
  <blockquote>
    <p>c:\program files\myApp\data\newFolder.</p>
  </blockquote>
  
  <p>This is function I use to create new folder and get errors:</p>
  
  <pre><code>if(!CreateDirectory(pathSamples,NULL))  //Throw Error
   {
    DWORD errorcode = GetLastError(); 
    LPVOID lpMsgBuf;
  
    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
         NULL, errorcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&amp;lpMsgBuf, 0, NULL );
  
    MessageBox(NULL, (LPCTSTR)lpMsgBuf, TEXT("Error"), MB_OK);
   }
  </code></pre>
  
  <p>In XP this works, but in Windows 7 it doesn't. If I run application as administrator than the folder is created, otherwise "Access is denied" error is thrown.</p>
  
  <p>My question is following: <br>
  <strong>Is there an option to make changes to the code so that the folder can be created in "program files" nad that files can be saved in this folder?</strong></p>
  
  <p>PS I saw <a href="https://stackoverflow.com/questions/4583200/how-to-copy-program-files-in-c-drive">this thread</a> already but it doesn't answer my question.</p>
  
  <p>Thanks,<br>
  Ilija</p>