title: How would I include Psapi.h without running into a multiply included error?
body: <p>Currently running into an issue where Winsock.h is already included in a header file elsewhere in my project...</p>
  
  <p>Header not directly included:</p>
  
  <pre><code># if defined(_WINSOCKAPI_) &amp;&amp; !defined(_WINSOCK2API_)
  # error WinSock.h has already been included
  # endif // defined(_WINSOCKAPI_) &amp;&amp; !defined(_WINSOCK2API_)
  </code></pre>
  
  <p>So that when I try to build, I get a the error "C1189 Winsock.h has already been included" (from the defined error message in the above piece of code).</p>
  
  <p>However, I need to be able to use <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms683219(v=vs.85).aspx" rel="nofollow noreferrer">parts of the PSAPI</a> to obtain memory usage information about the current process. I tried to include in my other file...</p>
  
  <p>My .cpp File:</p>
  
  <pre><code>#include &lt;Windows.h&gt;
  #include &lt;Psapi.h&gt;
  </code></pre>
  
  <p>...</p>
  
  <pre><code>SIZE_T getMemoryInfo() {    // The function that needs the includes
  
      PROCESS_MEMORY_COUNTERS pmc;
      SIZE_T memoryUsed;
  
      GetProcessMemoryInfo(GetCurrentProcess(), &amp;pmc, sizeof(pmc));
      memoryUsed = pmc.WorkingSetSize;
  
      return memoryUsed;
  
  }
  </code></pre>
  
  <p>After researching I then tried using WIN32_LEAN_AND_MEAN to try to get rid of the Winsock.h include, which works, but now when I try to use PROCESS_MEMORY COUNTERS I get an undefined symbol error... </p>
  
  <p>"LNK2019 unresolved external symbol GetProcessMemoryInfo referenced in function..." and "LNK1120 1 unresolved externals [in myFile]"</p>
  
  <p>I expect that I need to figure out how to include the actual header files I need, <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms682050(v=vs.85).aspx" rel="nofollow noreferrer">but the Windows docs do not say</a> (and <a href="https://en.wikipedia.org/wiki/Windows.h" rel="nofollow noreferrer">Wikipedia</a> says that most of the child headers cannot be individually included, so that's probably an issue).</p>
  
  <pre><code>#define WIN32_LEAN_AND_MEAN
  #include &lt;Windows.h&gt;    // Windows specific libraries for collecting software metrics.
  #include &lt;Psapi.h&gt;
  </code></pre>
  
  <p>I've been trying to figure this out for a full day, any help would be appreciated as Windows Docs are pretty unhelpful and I am thoroughly frustrated. I apologize if it is a stupid question, but I frequently struggle with includes.</p>