title: How enable dragging a file on the *.exe and get it as parameter?
body: <p>What do I have to do to make my program use a file that has been dragged and dropped onto its icon as a parameter?</p>
  
  <p>My current <code>main</code> method looks like this:</p>
  
  <pre><code>int main(int argc, char* argv[])
  {
      if (argc != 2) {
          cout &lt;&lt; "ERROR: Wrong amount of arguments!" &lt;&lt; endl;
          cout &lt;&lt; "\n" &lt;&lt; "Programm closed...\n\n" &lt;&lt; endl;
          exit(1);
          return 0;
      }
  
      Converter a(argv[1]);
      // ...
  
      cout &lt;&lt; "\n" &lt;&lt; "Programm finished...\n\n" &lt;&lt; endl;
  
      // cin.ignore();
      return 0;
  }
  </code></pre>
  
  <p>What I'd really like to be able to do is select 10 (or so) files, drop them onto the EXE, and process them from within my application.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The incomming parameter is used as filename, constructed in the cunstructor.</p>
  
  <pre><code>Converter::Converter(char* file) {
         // string filename is a global variable
     filename = file;
     myfile.open(filename.c_str(), ios_base::in);
  }
  </code></pre>
  
  <p>The method where the textfile gets read:</p>
  
  <pre><code>string Converter::readTextFile() {
  char c;
  string txt = "";
  
  if (myfile.is_open()) {
  
      while (!myfile.eof()) {
          myfile.get(c);
          txt += c;
      }
  
  } else {
      error("ERROR: can't open file:", filename.c_str());
  }
  return txt;
  }
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT2:</strong>
  deleted</p>
  
  <p><strong>Update:</strong><br>
  I got again to this point.</p>
  
  <p>Actual <code>Main</code> method:  </p>
  
  <pre><code>// File path as argument
  </code></pre>
  
  <p>int main(int argc, char* argv[]) {
      if (argc &lt; 2) {
          cout
              &lt;&lt; "ERROR: Wrong amount of arguments! Give at least one argument ...\n"
              &lt;&lt; endl;
          cout &lt;&lt; "\n" &lt;&lt; "Programm closed...\n\n" &lt;&lt; endl;
          cin.ignore();
          exit(1);
          return 0;
          }</p>
  
  <pre><code>vector&lt;string&gt; files;
  
  for (int g = 1; g &lt; argc; g++) {
      string s = argv[g];
      string filename = "";
      int pos = s.find_last_of("\\", s.size());
  
      if (pos != -1) {
          filename = s.substr(pos + 1);
  
          cout &lt;&lt; "argv[1] " &lt;&lt; argv[1] &lt;&lt; endl;
          cout &lt;&lt; "\n filename: " &lt;&lt; filename &lt;&lt; "\n pos: " &lt;&lt; pos &lt;&lt; endl;
          files.push_back(filename);
  
          }
      files.push_back(s);
      }
  
  for (unsigned int k = 0; k &lt; files.size(); k++)
      {
      cout &lt;&lt; "files.at( " &lt;&lt; k &lt;&lt; " ): " &lt;&lt; files.at(k).c_str() &lt;&lt; endl;
      Converter a(files.at(k).c_str());
      a.getATCommandsFromCSV();
      }
  
  
  cout &lt;&lt; "\n" &lt;&lt; "Programm finished...\n\n" &lt;&lt; endl;
  
  cin.ignore();
  
  return 0;
  }
  </code></pre>
  
  <p>Actually the console window apears for maybe 0.5 sec and closes again.<br>
  It doen't stop on any of my <code>cin.ignore();</code> Maybe it doesn't get there?  </p>
  
  <p><strong>Can anyone help?</strong></p>