Uniface User Forum

 View Only
  Thread closed by the administrator, not accepting new replies.
  • 1.  Uniface 4GL: How to find current user on the OS

    ROCKETEER
    Posted 11-19-2018 11:58
    No replies, thread closed.

    How to find current user on the OS

    Author: antoine.picaud@free.fr (apicaud)

    Hi, I would like to known the name of the current user. I think, I can add advapi32.dll in a signature to call the function GetUserName but I don't known how make this integration. Have you a solution about the problem ? Regards



  • 2.  RE: Uniface 4GL: How to find current user on the OS

    ROCKETEER
    Posted 11-19-2018 11:58
    No replies, thread closed.

    In the download section of the Uniface Community, you find an article about integrationg Windows API from George Mockford. http://www.communityzero.com/clubs/files/index.jsp?folderid=2112110&SRref=1&PNref=1&objectid=1367844&uid=1E60DF81B09699DC855D946B6270970B11C31979CC1&clubid=723272&tool=files&action=read Success, Uli P.S. Nowadays you have a choice between GetUsernameA (ascii) and GetUsernameW (Unicode).


    Author: ulrich-merkel (ulrichmerkel@web.de)


  • 3.  RE: Uniface 4GL: How to find current user on the OS

    ROCKETEER
    Posted 11-19-2018 11:58
    No replies, thread closed.

    Thanks, it's a good solution.

    I've integrated signature of GetUsernameA currently but I need also GetUsernameW for Unicode.

    Regards,

    Antoine


    Author: apicaud (antoine.picaud@free.fr)


  • 4.  RE: Uniface 4GL: How to find current user on the OS

    ROCKETEER
    Posted 11-19-2018 11:58
    No replies, thread closed.

    Hi,

    As has been said above, the username is available in an environment variable, USERNAME on Windows, USER on Unix, SYS$LOGIN on VMS.

    Since 9.3, you can use

      myvar = $setting("", "MYVAR", "ENVDATA")

    to get the value of environment variables; in your case $setting("", "USERNAME", "ENVDATA") may do the trick. Note that $setting is currently undocumented and unsupported.

    Etienne


    Author: etienne (etienne_thijsse@compuware.com)


  • 5.  RE: Uniface 4GL: How to find current user on the OS

    ROCKETEER
    Posted 11-19-2018 11:58
    No replies, thread closed.

    Hi Etienne,

    It's not a good solution, the envdata can be modify directly in a program.

    I use now directly the signature with dll of Windows (kernel32.dll) with the function getusernamea

        activate "kernel32".GETUSERNAMEA($$xUser, "255")
     

    And in the asn file, I specify also the dll.

    By, Antoine


    Author: apicaud (antoine.picaud@free.fr)


  • 6.  RE: Uniface 4GL: How to find current user on the OS

    ROCKETEER
    Posted 11-19-2018 11:58
    No replies, thread closed.

    Hi Etienne and Antoine,

    i guess, there is no great difference between using the dll or the $setting method (which at this moment is new to me- thx for the hint).

    @Antoine: yes, you are right. The data can be modified. But isnt the question when?!

    see, what i mean is that if you open a shell (and i guess its somekind of what happens when uniface fires up), you get a set of environmentvars with you. If you choose to modify the data wiithin Uniface, then it isn't global (or is it?)

    The only chance we have is to rely on, whats in the environment. And so i guess, the result will be the same no matter which path you want to go.

    .oO(Or should i be so wrong in this?!)

    Cheers,

    -GHAN- :)


    Author: -GHAN- (hansen@ahp-gmbh.de)


  • 7.  RE: Uniface 4GL: How to find current user on the OS

    ROCKETEER
    Posted 11-19-2018 11:58
    No replies, thread closed.

    Hi there,

    maybe its not exactly what you look for but you could do the following without integrating a DLL ;)

    Simply look in the Environment!

    ---8<--------

    C:\SET

    USERNAME=CPTFUTURE ... ...

    ---8<--------

    This should be possible since Windows 3.x i guess and is slightly compatible to UNIX/LINUX environments aswell. If you prefer to use a DLL for the JOB, the choice should be as mentioned from Uli Merkel

     

    a nice Weekend to you,

     

    -GHAN-


    Author: -GHAN- (hansen@ahp-gmbh.de)