title: Win API GetUserName returns SYSTEM
body: <p>I have this method for getting user name of current logged in user, It works fine when I run my application as console application, But when I run it as a windows service, It gives me <code>SYSTEM</code> as user name! Any Idea to achieve my desired behavior even if I run my application as windows service?</p>
  
  <pre><code>bool GetCurrentUserName(std::wstring&amp; userName)
  {
      const int INFO_BUFFER_SIZE = 32767;
      TCHAR infoBuf[INFO_BUFFER_SIZE] = L"";
      DWORD bufCharCount = INFO_BUFFER_SIZE;
  
      if (GetUserName(infoBuf, &amp;bufCharCount))
      {
          userName = std::wstring(infoBuf);
          return true;
      }
      return false;
  }
  </code></pre>