Date: Fri, 16 Apr 1999 10:59:16 GMT
Reply-To: Evanspuk <evanspuk@AOL.COMNOSPAM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Evanspuk <evanspuk@AOL.COMNOSPAM>
Organization: AOL, http://www.aol.co.uk
Subject: Re: Get username from Windows
In article <7f6qei$fek$1@news.capgemini.se>, "Fredrik Hedvall"
<Fredrik.Hedvall@capgemini.se> writes:
>Subject: Get username from Windows
>From: "Fredrik Hedvall" <Fredrik.Hedvall@capgemini.se>
>Date: Fri, 16 Apr 1999 09:54:04 +0200
>
>Hi everyone!
>
>I need to obtain the username from the windows environment into an scl or
>macro variable. Does anyone have a nice API-call which can fetch the userid?
>
>Yours
>
>Fredrik H
Fredrik
The following code will get the windows username for you. Obviously the
lines between the cards; and ;;;; lines are what goes in to the SASCBTBL
file.
Hope this helps
Peter Evans
filename sascbtbl 'winapi.txt';
run;
data _null_;
infile cards truncover;
file sascbtbl;
input @1 record $char80.;
put record $char80.;
cards4;
routine GetUserNameA
module=ADVAPI32
minarg=2
maxarg=2
stackpop=called
returns=short
;
arg 1 char update format=$cstr20.; * User name ;
arg 2 num update format=pib4. ; * User name length;
;;;;
run;
data _null_;
length userid $20;
userid = '';
userlen = 20;
rc = modulen('GetUserNameA',userid,userlen);
call symput('zuserid',userid);
run;
filename sascbtbl clear;
run;
%put NOTE: Windows userid = &zuserid;