Board index » delphi » getting network user's username

getting network user's username

I'd like to know how in Delphi to get the username, and perhaps the
machine name in use.  I don't know how this differs based on different
networks, like Netware, NT, etc.  I'm hoping there is a simple Windows
API call for this.  I'd like something that works on all variations
of Windows, 3.1, 95, and NT, if possible.

Thanks.

 

Re:getting network user's username


Quote
SDRG wrote:

> I'd like to know how in Delphi to get the username, and perhaps the
> machine name in use.  I don't know how this differs based on different
> networks, like Netware, NT, etc.  I'm hoping there is a simple Windows
> API call for this.  I'd like something that works on all variations
> of Windows, 3.1, 95, and NT, if possible.

> Thanks.

Win API 3.1 has no call for it, IMHO. I think quering the Registry would
be the soulution.
--
--Shundi
mailto:shu...@nue.et-inf.uni-siegen.de

/*  
    I guarantee that I'll have an especialy gruesome place
    in hell for programmers who write uncommented code
                                           Pournelle    */

Re:getting network user's username


Quote
Shundi <shu...@nue.et-inf.uni-siegen.de> wrote:
>SDRG wrote:

>> I'd like to know how in Delphi to get the username, and perhaps the
>> machine name in use.  I don't know how this differs based on different
>> networks, like Netware, NT, etc.  I'm hoping there is a simple Windows
>> API call for this.  I'd like something that works on all variations
>> of Windows, 3.1, 95, and NT, if possible.

>> Thanks.

>Win API 3.1 has no call for it, IMHO. I think quering the Registry would
>be the soulution.
>--

A simple, if inelegant, solution is to get the Username parameter from
the [network] section of SYSTEM.INI file.  Only works for WFWg??

Re:getting network user's username


Quote
Gary Cramblitt wrote:

> Shundi <shu...@nue.et-inf.uni-siegen.de> wrote:

> >SDRG wrote:

> >> I'd like to know how in Delphi to get the username, and perhaps the
> >> machine name in use.  I don't know how this differs based on different
> >> networks, like Netware, NT, etc.  I'm hoping there is a simple Windows
> >> API call for this.  I'd like something that works on all variations
> >> of Windows, 3.1, 95, and NT, if possible.

> >> Thanks.

> >Win API 3.1 has no call for it, IMHO. I think quering the Registry would
> >be the soulution.
> >--

> A simple, if inelegant, solution is to get the Username parameter from
> the [network] section of SYSTEM.INI file.  Only works for WFWg??

Be advised that although Windows for Workgroups supports limited
peer-to-peer networking, it does not support non-WFWg networks, such as
Netware, Banyan VINES, MS-LAN, TCP/IP, etc.  Each network you wish to
support MUST be detected and handled via (non-Windows) API calls to that
specific network.  There is no magic GetUserName API call available.
Querying the registry will not work, as most networks politely ignore
Windows, providing virtual drive management beneath it.  I would
recommed that you pick up some 3rd party books on network programming or
contact the vendors that you wish to support, and call their APIs
directly from your application (or DLL).  You should note that most
network APIs are presented via interrupts.  This may lead to some
unfashionable code, but may be the only way possible to get the results
that you need.  Novell, for instance, is installed as a TSR that hooks
the Network Multiplexer Interrupt (Int $2F), as is MSCDEX and many disk
compression tools.

For more information, consult one or more of the following excellent
books:

  Client/Server LAN Programming, by Barry Nance
  ISBN:   1-56529-924-8
  Undocumented DOS, by Andrew Schulman, et al.
  ISBN:   0-201-63287-X
  PC Interrupts, by Ralf Brown & Jim Kyle
  ISBN:   0-201-62485-0

Good luck,

Michael Gaskill
mgask...@qni.com

Re:getting network user's username


Quote
SDRG <sdrs...@ix.netcom.com> wrote:
>I'd like to know how in Delphi to get the username, and perhaps the
>machine name in use.  I don't know how this differs based on different
>networks, like Netware, NT, etc.  I'm hoping there is a simple Windows
>API call for this.  I'd like something that works on all variations
>of Windows, 3.1, 95, and NT, if possible.
>Thanks.

For WfW, as suggested in a previous post, you can take a look in the
ini file

For Win95 (and NT4?)  you can use the WNet API which does a good job
of hiding the different network variants out there. It's much simpler
to get the info from the Registry, -
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\CurrentUser

Other Threads