外部DLLを利用したユーザIDの取得
[OS]
[リリース]
[キーワード]
[質問]Windows95 や WindowsNTでSASを使用している場合、ログオンしているユーザのIDを取得する方法はありますか。
[回答]
外部DLL呼び出しの機能(SAS 6.11)を使用して、Win32 API GetUserName関数によってユーザIDを取得することができます。
filename SASCBTBL 'tmp.txt';
/* 属性テーブルの作成 */
data _null_;
file sascbtbl;
put 'routine GetUserNameA';
put ' minarg=2';
put ' maxarg=2';
put ' stackpop=called';
put ' module=advapi32';
put ' returns=short;';
put 'arg 1 update format=$cstr200.; ';
put 'arg 2 num input format=pib4.; ';
run;
data _null_;
length userid $20;
/* OSの判定 */
if "&sysscpl" ne 'WIN_95' and "&sysscpl" ne 'WIN_NT' then do;
put 'Windows 95 or Windows NT環境でのみ動作します.';
stop;
end;
/* ユーザIDの取得 */
rc = modulen('GetUserNameA', userid, 20);
if rc=0 then
put '特定のユーザIDでログオンしていません.';
else
put userid=;
run;
|
|