Finding logged on UserName in NT 4.0 using Delphi

Quote
On Wed, 3 Jun 1998 19:37:38 -0700, "Tob" <ejod...@inetex.com> wrote:
>How can I find out the user name when the user is logged into a  NT 4.0
>workstation.

If your application uses the BDE, you can use the following code to
get the user logged on:

------------------------------------------------------------------------------------
function GetCurrUser : String;
var pcNetUser : PChar;
begin
  pcNetUser := StrAlloc (256);
  if DbiGetNetUserName (pcNetUser) = 0 then begin
    Result := StrPas (pcNetUser);
  end
  else begin
    Result := '';
  end;
  StrDispose (pcNetUser);
end;
------------------------------------------------------------------------------------

Quote
> Can I do the same for 95 ?  and if not what is the call to find out what
>OS my app is running on...

This code works for Win95 and NT 3.51/4.0. Doesn't work on Win 3.x
though.....

Marc

--------------------------------------------------------------------------
Marc Scheuner                            Berner Versicherungen, Dept. ISV
                                         Laupenstrasse 27
marc.scheu...@berner.ch                  CH-3001 BERNE, Switzerland
--------------------------------------------------------------------------