title: Check if the username logged on windows is the same as the one who ran the program - C++
body: <p>When I try to compile the code (showed below) I get those 2 errors:</p>
  
  <p><code>- reference to the external simbol _WTSQuerySessionInformationW@20 not solved in the function void_cdecl Test(void)" (?Test@@YAXXZ);</code></p>
  
  <p><code>- reference to the external simbol _WTSFreeMemory@20 not solved in the function void_cdecl Test(void)" (?Test@@YAXXZ)</code></p>
  
  <p>The purpose was to output the name of the username logged on windows and the username who ran the program, but I got those 2 mistakes while compiling.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  #include &lt;Windows.h&gt;
  #include &lt;wtsapi32.h&gt;
  #include &lt;Lmcons.h&gt;
  
  void Test()
  {
      WCHAR  UsernameSSR[UNLEN + 1];
      DWORD  bufCharCountSSR = UNLEN + 1;
  
      if (GetUserNameW(UsernameSSR, &amp;bufCharCountSSR))
          std::wcout &lt;&lt; L"UsernameSSR: " &lt;&lt; UsernameSSR &lt;&lt; std::endl;
      else
          std::wcout &lt;&lt; L"Error getting UserNameSSR" &lt;&lt; std::endl;
  
  
      LPWSTR UsernameWindows;
      DWORD  bufByteCountWindows;
  
      if (WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSUserName, &amp;UsernameWindows, &amp;bufByteCountWindows))
      {
          LPWSTR Domain;
          DWORD bufByteCountDomain;
  
          std::wcout &lt;&lt; L"UsernameWindows: ";
  
          if (WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSDomainName, &amp;Domain, &amp;bufByteCountDomain))
          {
              if (*Domain)
                  std::wcout &lt;&lt; Domain &lt;&lt; L"\\";
              WTSFreeMemory(Domain);
          }
  
          std::wcout &lt;&lt; UsernameWindows &lt;&lt; std::endl;
  
          WTSFreeMemory(UsernameWindows);
      }
      else
          std::wcout &lt;&lt; L"Error getting UserNameWindows" &lt;&lt; std::endl;
  
  }
  int main() {
      Test();
      return 0;
  }
  </code></pre>