title: Hiding command prompt called by system();
body: <p>Goodday, I have script,that loops all files in directory, but I need to hide console while looping them this way.
  Here is part of script:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;Windows.h&gt;
  using namespace std;
  
   int GetFilesInDirectory(const char * dir,string dest[],unsigned int max){
      string loc=dir;
      int ctr=0;
      if(loc.length()&gt;2)
          if(loc.substr(loc.length()-2,1)=="\\")
              loc=loc.substr(0,loc.length()-1);
      string opcommand;
      string delcommand;
      if(loc.length()&gt;2){
          opcommand="cd "+(loc)+" &amp;&amp; dir /s /b /a &gt; tmpfile.cpptmp";
          delcommand="cd "+(loc)+" &amp;&amp; del tmpfile.cpptmp";
      } else {
          opcommand="dir /s /b /a &gt; tmpfile.cpptmp";
          delcommand="del tmpfile.cpptmp";
      }
      system(opcommand.c_str());
      ifstream f;
      string line;
      string fileloc;
      if(loc.length()&gt;2)
          fileloc=(loc)+"\\tmpfile.cpptmp";
      else fileloc="tmpfile.cpptmp";
      f.open(fileloc,ios::binary);
      while(f.good()){
          getline(f,line);
          if(line.length()&gt;1&amp;&amp;ctr&lt;max){
              dest[ctr]=line;
              ctr++;
          }
      }
      f.close();
      system(delcommand.c_str());
      return ctr;
  }
  int main() {
      FreeConsole();
      const unsigned int filescountmax=16184;
  
      string files[filescountmax];
      int count=GetFilesInDirectory("\\",files,filescountmax);
      string ext;
      for(int i=0;i&lt;count;i++){
              //some script
  
      }
  }
  </code></pre>
  
  <p>When process starts, it hides it self, but after while it shows up cmd.exe, which closes it self.
  By the way, I know there are other ways to loop files in directory, but this is easiest way to loop also files in subdirs and subdirs of subdirs and so on.
  Can you help me, please?</p>