bool TFormMain::GetCurrentProcessUser(AnsiString& strUserName)
{
bool bRet = false;
//strUserName.Empty();
try
{
  DWORD dwSize = MAX_PATH;
  TCHAR *pszName = new TCHAR[dwSize];
  if (!GetUserName(pszName, &dwSize))
  {
    delete[] pszName;
    pszName = new TCHAR[dwSize];
    bRet = GetUserName(pszName, &dwSize);
  }   if (pszName != NULL)
  {
    strUserName = pszName;
    delete[] pszName;
  }
}
catch (...)
{
  bRet = false;
} return bRet;
}
05-27 18:20