Delphi แสดง Domain User ที่ login

Delphi สามารถดึงเอาข้อมูลที่ User Login มาใช้ประโยชน์ได้โดยใช้คำสั่ง ดังนี้

function TForm3.GetDomainLogin: string;
const
cnMaxUserNameLen = 254;
var
vlDomainName : array[0..MAXCHAR] of char;
vlSize : ^DWORD;
sUserName : string;
dwUserNameLen : DWord;
FullDomainUser : String;
begin
New(vlSize);
vlSize^ := MAXCHAR;
ExpandEnvironmentStrings(PChar(‘%USERDOMAIN%’), vlDomainName, vlSize^);
Dispose(vlSize);

dwUserNameLen := cnMaxUserNameLen-1;
SetLength( sUserName, cnMaxUserNameLen );
GetUserName(
PChar( sUserName ),
dwUserNameLen );
SetLength( sUserName, dwUserNameLen );

FullDomainuser := vlDomainName;
FullDomainuser := FullDomainuser +’\’+ sUserName;
Result := FullDomainuser;

end;

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response