Board index » delphi » Getting Network User Info from WIN95 in Delphi 2.0

Getting Network User Info from WIN95 in Delphi 2.0

Hello Again--

        I am working on a C/S program in Delphi 2.0 and part of the program
requires the user to enter his/her initials (select them from a drop down
box) but I am looking for a way to automate this by grabbing the user name
from the network log-in. Can this be done in Delphi 2.0 ? (we are using
Windows '95)

        Thanks

Rich Morey
richard.mo...@factory.com

 

Re:Getting Network User Info from WIN95 in Delphi 2.0


If you have the Win32 SDK, you can lookup the function WNETGetUser. This
allows you to get the username of the currently logged on user

Johan Kotze

Quote
> "Richard Morey" <richard.mo...@factory.com> wrote in article

<01bb57f5.f8438840$9d708...@NONE.factory.com>...
Quote
> Hello Again--

>    I am working on a C/S program in Delphi 2.0 and part of the program
> requires the user to enter his/her initials (select them from a drop
down
> box) but I am looking for a way to automate this by grabbing the user
name
> from the network log-in. Can this be done in Delphi 2.0 ? (we are using
> Windows '95)

>    Thanks

> Rich Morey
> richard.mo...@factory.com

Re:Getting Network User Info from WIN95 in Delphi 2.0


        In article <01bb57f5.f8438840$9d708...@NONE.factory.com>, "Richard

Quote
Morey" <richard.mo...@factory.com> wrote:
>Hello Again--

>        I am working on a C/S program in Delphi 2.0 and part of the program
>requires the user to enter his/her initials (select them from a drop down
>box) but I am looking for a way to automate this by grabbing the user name
>from the network log-in. Can this be done in Delphi 2.0 ? (we are using
>Windows '95)

>        Thanks

>Rich Morey
>richard.mo...@factory.com

Here's my code that calls the WinAPI.

function TExplorer.GetNetUser: Boolean;
var
   user: PChar;
   x: Integer;
   QryUser: TQuery;
begin
x:=30;
if getUserName(user, x) then
   begin
      UserInfo[1]:=StrPas(user);
      Result:=true
   end
else Result:=False;

Cheers, Simon

Re:Getting Network User Info from WIN95 in Delphi 2.0


Quote
Richard Morey wrote:

> Hello Again--

>         I am working on a C/S program in Delphi 2.0 and part of the program
> requires the user to enter his/her initials (select them from a drop down
> box) but I am looking for a way to automate this by grabbing the user name
> from the network log-in. Can this be done in Delphi 2.0 ? (we are using
> Windows '95)

>         Thanks

> Rich Morey
> richard.mo...@factory.com

You can try this, I haven't tried it personally yet, but a friend swears by it . .or is that
swears at it??  Let me know if it helps.

You can do it with the Windows API Function WNetGetUser. But this doesnt
always seem to work correctly, reason unknown.

There is a function from Borland which worked every fine so far:

function DbiGetNetUserName (pszNetUserName: PChar): DBIResult stdcall;

It is included in the BDE. You can find a description of it in theBDE32.HLP

Ted Herrlich
--

"The Pen is Mightier than the Sword, unless you are One on One."

Other Threads