jfreisen
asked on
Get network username
I am using Delphi 3 on a Novell network. How do I get the name of the user logged in?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
it's almost the same, but i prefer dynamically allocating and disposing the buffer...
function GetUserName: string;
var
dwSize: DWord;
p: PChar;
begin
dwSize := 1024;
p := StrAlloc(Succ(dwSize));
if GetUserName(p, dwSize) then
Result := StrPas(p)
else begin
Result := 'none';
GetLastError;
end;
StrDispose(p);
end;
regards,
BlackDeath.
function GetUserName: string;
var
dwSize: DWord;
p: PChar;
begin
dwSize := 1024;
p := StrAlloc(Succ(dwSize));
if GetUserName(p, dwSize) then
Result := StrPas(p)
else begin
Result := 'none';
GetLastError;
end;
StrDispose(p);
end;
regards,
BlackDeath.
function TForm1.GetMyNetUserName: string;
begin
SetLength(Result, dbiMaxUserNameLen + 1);
Check(DbiGetNetUserName(PC har(Result )));
SetLength(Result, StrLen(PChar(Result)));
end;
begin
SetLength(Result, dbiMaxUserNameLen + 1);
Check(DbiGetNetUserName(PC
SetLength(Result, StrLen(PChar(Result)));
end;
Epsylon,
I tried to send you an email and it came back. We are doing a survey of our top 100 experts to find out what improvements they would like at the site. Please send me an up-to-date email address.
Linda Gardner
Customer Service @ Experts Exchange
linda@experts-exchange.com
I tried to send you an email and it came back. We are doing a survey of our top 100 experts to find out what improvements they would like at the site. Please send me an up-to-date email address.
Linda Gardner
Customer Service @ Experts Exchange
linda@experts-exchange.com
var name: array[0..63] of Char;
size: Cardinal;
begin
size := 64;
if GetUserName(@name, size) then
ShowMessage(name);
end;