Показать сообщение отдельно
  #2  
Старый 11.04.2012, 13:33
flyxman flyxman вне форума
Прохожий
 
Регистрация: 11.04.2012
Сообщения: 2
Репутация: 10
По умолчанию

У всех прошу прощения, разобрался.

Ответ нашелся на этом же сайте.

Код:
 { 
  Windows NT/2000/XP: 

  The GetUserNameEx function retrieves the name of the user or other 
  security principal associated with the calling thread. 
  You can specify the format of the returned name. 
  If the thread is impersonating a client, GetUserNameEx 
  returns the name of the client. 
}

 const
   NameUnknown = 0; // Unknown name type. 
  NameFullyQualifiedDN = 1;  // Fully qualified distinguished name 
  NameSamCompatible = 2; // Windows NT® 4.0 account name 
  NameDisplay = 3;  // A "friendly" display name 
  NameUniqueId = 6; // GUID string that the IIDFromString function returns 
  NameCanonical = 7;  // Complete canonical name 
  NameUserPrincipal = 8; // User principal name 
  NameCanonicalEx = 9;
   NameServicePrincipal = 10;  // Generalized service principal name 
  DNSDomainName = 11;  // DNS domain name, plus the user name 


procedure GetUserNameEx(NameFormat: DWORD;
   lpNameBuffer: LPSTR; nSize: PULONG); stdcall;
   external 'secur32.dll' Name 'GetUserNameExA';


 function LoggedOnUserNameEx(fFormat: DWORD): string;
 var
   UserName: array[0..250] of char;
   Size: DWORD;
 begin
   Size := 250;
   GetUserNameEx(fFormat, @UserName, @Size);
   Result := UserName;
 end;

 procedure TForm1.Button1Click(Sender: TObject);
 begin
   Edit1.Text := LoggedOnUserNameEx(NameDisplay);
 end;
Ответить с цитированием