Board index » delphi » HELP: Getting Username for current domain

HELP: Getting Username for current domain

In my application I have a login box with a TEdit for username. I want to put in this TEdit the
username that the user used to login into the current domain/workgroup. Is it possible?

Thanks in advance,

--
Billy Nice

====================================================================
E-Mail: bi...@sysgenics.co.uk        SysGenics Limited  
Telephone: +44 0181 296 9091         Central House, 1 Alwyne Road
Fax: +44 0181 296 9160               Wimbledon, London, SW19 7AB, UK
====================================================================

 

Re:HELP: Getting Username for current domain


Quote
Billy Nice <bi...@sysgenics.co.uk> wrote:
>In my application I have a login box with a TEdit for username. I want to put in this TEdit the
>username that the user used to login into the current domain/workgroup. Is it possible?

See if something like this will work for you:
-------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
var
  buf: array[0..127]of char; // (128 is probably more than you need)
begin
  buf[GetEnvironmentVariable('USERNAME',buf,128)]:=#0;
  Edit1.SetTextBuf(buf);
end;
--------------------------------------------------
Seems to work with D2 on NT3.51

Regards,
Bengt Richter

Re:HELP: Getting Username for current domain


GetUserName is a better choice for D2.

--
Mark Pritchard

Bengt Richter <b...@accessone.com> wrote in article
<51ch65$...@kanga.accessone.com>...

Quote
> Billy Nice <bi...@sysgenics.co.uk> wrote:

> >In my application I have a login box with a TEdit for username. I want

to put in this TEdit the
Quote
> >username that the user used to login into the current domain/workgroup.
Is it possible?

> See if something like this will work for you:
> -------------------------------------------------
> procedure TForm1.Button1Click(Sender: TObject);
> var
>   buf: array[0..127]of char; // (128 is probably more than you need)
> begin
>   buf[GetEnvironmentVariable('USERNAME',buf,128)]:=#0;
>   Edit1.SetTextBuf(buf);
> end;
> --------------------------------------------------
> Seems to work with D2 on NT3.51

> Regards,
> Bengt Richter

Other Threads