title: C++: How to set a new wndProc for a console application?
body: <p>If I have a console application with a handle to it set up like so;</p>
  
  <pre><code>HWND hWnd = GetConsoleWindow();
  </code></pre>
  
  <p>Then how do I set up a new wndProc for the window?<br>
  I tried using</p>
  
  <pre><code>SetWindowLong(hWnd, GWL_WNDPROC, (LONG)conProc);
  </code></pre>
  
  <p>With conProc being defined as</p>
  
  <pre><code>LRESULT CALLBACK conProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  {
      switch(msg)
      {
          case WM_NCHITTEST:
              return HTCAPTION;
      }
      return DefWindowProc(hWnd, msg, wParam, lParam );
  }
  </code></pre>
  
  <p>But it doesn't work and says "Error code: 5 - Access is denied" on <code>GetLastError()</code></p>
  
  <p>I understand that it's pretty difficult to modify the console application like this, since it's a csrss.exe application and all, but I'd still like to try..
  Thanks.</p>