Board index » delphi » User Name - PLEASE HELP!

User Name - PLEASE HELP!

I am inserting into a table in my application and one of the fields I
populate is a UserName field. How can I pick up the User Name that I logged
in as in the default Login Prompt window. I've tried 'GetUserName' - and
this results in 'Not enough actual parameters'. There is no more help in my
manuals or in the online help regarding this.

PLEASE HELP somebody!
I would be most appreciative.
Thanks
Bronwen

--
braat...@terminal.rennies.co.za

 

Re:User Name - PLEASE HELP!


In article <01bc69c2$59407660$43f1e...@braatgev.rennies.co.za>, Bronwen
Raatgever <braat...@terminal.rennies.co.za> writes

Quote
>I am inserting into a table in my application and one of the fields I
>populate is a UserName field. How can I pick up the User Name that I logged
>in as in the default Login Prompt window. I've tried 'GetUserName' - and
>this results in 'Not enough actual parameters'. There is no more help in my
>manuals or in the online help regarding this.

Which 'Login Prompt' ... e.g. WorkGroups for Windoze, Windoze 95 ...

John

+-------------------+--------------------------------------------------+
John P.McCreesh     | Net:   john.mccre...@forbolancs.co.uk
Forbo-Lancaster Ltd.| X.400: c=GB,a=CWMAIL,p=FORBO,s=McCreesh
Lancaster, England  | Voice: +44 (0)1524 65222 Fax: +44 (0)1524 61638

Re:User Name - PLEASE HELP!


In article <01bc69c2$59407660$43f1e...@braatgev.rennies.co.za>,
braat...@terminal.rennies.co.za says...

Quote

>I am inserting into a table in my application and one of the fields I
>populate is a UserName field. How can I pick up the User Name that I logged
>in as in the default Login Prompt window. I've tried 'GetUserName' - and
>this results in 'Not enough actual parameters'. There is no more help in my
>manuals or in the online help regarding this.

>PLEASE HELP somebody!
>I would be most appreciative.
>Thanks
>Bronwen

>--
>braat...@terminal.rennies.co.za

Well, if you're talking about the Win95/NT4 type username,
then you can use this function to retrieve it.

...

uses
  Windows;

function _GetUserName: String;
var
  arrTemp: array [0..MAX_PATH+1] of Char;
  intTemp: Integer;
begin
  Result := '';
  intTemp := SizeOf(arrTemp);
  if (GETUSERNAME(arrTemp,intTemp)) then Result := arrTemp;
end;

This is a very basic function -- you can spice it up with whatever
functionality you desire.

----------------------------------------
A. Downey
Logical Information Services, Inc.
adow...@logicalinfo.com
http://www.logicalinfo.com
----------------------------------------

Re:User Name - PLEASE HELP!


On 26 May 1997 11:48:14 GMT, "Bronwen Raatgever"

Quote
<braat...@terminal.rennies.co.za> wrote:
>I am inserting into a table in my application and one of the fields I
>populate is a UserName field. How can I pick up the User Name that I logged
>in as in the default Login Prompt window. I've tried 'GetUserName' - and
>this results in 'Not enough actual parameters'. There is no more help in my
>manuals or in the online help regarding this.

Bronwen,

use the GetUserName function which is part of the Windows API (see
Win32.hlp).

You will have to declare and array of PChar

var
  userp: array[0..80] of Char;
  user: string;
  n: integer;
begin
  n:=80;
  GetUserName(userp,n);
  user:=StrPas(userp)
end;

Russell Weetch
and UK Index is at http://www.ukindex.co.uk

Other Threads