title: Getting a list of all open windows in c++ and storing them
body: <p>I'm currently trying to get a list of all opened windows and storing them inside a vector. I've been looking at the code so much that the solution could be very easy but I don't seem to get it done without a global variable (which I want to avoid).</p>
  
  <p>Here is the code:</p>
  
  <pre><code>#include "stdafx.h"
  #include "json.h"
  #include &lt;algorithm&gt;  
  
  using namespace std;
  vector&lt;string&gt; vec;
  
  
  BOOL CALLBACK speichereFenster(HWND hwnd, LPARAM substring){
      const DWORD TITLE_SIZE = 1024;
      TCHAR windowTitle[TITLE_SIZE];
  
      GetWindowText(hwnd, windowTitle, TITLE_SIZE);
      int length = ::GetWindowTextLength(hwnd);
  
      wstring temp(&amp;windowTitle[0]);
      string title(temp.begin(), temp.end());
  
  
  
      if (!IsWindowVisible(hwnd) || length == 0 || title == "Program Manager") {
          return TRUE;
      }
  
      vec.push_back(title);
  
      return TRUE;
  }
  
  int main() {
      EnumWindows(speichereFenster, NULL);
      cin.get();
      return 0;
  }
  </code></pre>
  
  <p>I want to store all titles in the vector but I don't know how as I can't pass the vector into the function...</p>
  
  <p>Thanks!!!</p>