cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
%3CLINGO-SUB%20id%3D%22lingo-sub-3464%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ENom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3464%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ESalut%20jmpers%2C%3CBR%20%2F%3E%3CBR%20%2F%3E%20J'ai%20besoin%20de%20cr%C3%A9er%20une%20application%20dans%20jmp%20pour%20diff%C3%A9rents%20utilisateurs%2C%20ce%20qui%20signifie%20que%20diff%C3%A9rents%20utilisateurs%20auront%20une%20interface%20utilisateur%20diff%C3%A9rente.%20(c'est%20la%20m%C3%AAme%20application)%20Je%20me%20demandais%20s'il%20y%20avait%20un%20moyen%20d'obtenir%20un%20profil%20d'utilisateur%20%3F%20Disons%20le%20nom%20de%20l'ordinateur%2C%20le%20nom%20d'utilisateur%20ou%20le%20nom%20du%20serveur%20de%20jmp%26nbsp%3B%3F%20Ce%20faisant%2C%20je%20peux%20d%C3%A9cider%20quel%20script%20ouvrir%3CBR%20%2F%3E%3CBR%20%2F%3E%20r%C3%A9servoirs%3CBR%20%2F%3E%3CBR%20%2F%3E%20pniel%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-84899%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84899%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EPour%20MacOS%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEssaye%20%C3%A7a%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EIf(%20Host%20is(%20%22Mac%22%20)%2Cusername%3DGet%20Environment%20Variable(%20%22USER%22%20)%3B%0A%20stamp%3D%22Test%20%22%7C%7Cusername%7C%7C%22%2C%20%22%7C%7Cchar(today())%3B%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-80209%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80209%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EG%C3%A9nial!%20merci%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-80192%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80192%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EVous%20pouvez%20utiliser%20une%20boucle%20For()%2C%20ou%20vous%20pouvez%20faire%20quelque%20chose%20comme%20ci-dessous%20%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Adt%20%3D%20Open(%20%22%24SAMPLE_DATA%2FConsumer%20Preferences.jmp%22%20)%3B%0A%0Auname%20%3D%20Get%20Environment%20Variable(%20%22COMPUTERNAME%22%20)%3B%0A%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%20%22User%22%2C%20character%2C%20set%20each%20value(%20uname%20)%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-80117%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80117%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ECela%20fonctionne.%20Mais%20que%20se%20passe-t-il%20si%20j'ai%2010%20lignes%20et%20que%20je%20veux%20avoir%20uname%20dans%20toutes%20les%20lignes%20%3F%3C%2FP%3E%3CP%3EDois-je%20utiliser%20une%20boucle%20for%20%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-80054%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80054%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EVous%20devez%20indiquer%20%C3%A0%20JMP%20la%20ligne%20du%20tableau%20de%20donn%C3%A9es%20pour%20la%20colonne%20Utilisateur%20dans%20laquelle%20vous%20souhaitez%20enregistrer%20la%20valeur.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Euname%20%3D%20Get%20Environment%20Variable(%20%22COMPUTERNAME%22%20)%3B%0Adt%3Auser%5B1%5D%20%3D%20uname%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ECe%20qui%20pr%C3%A9c%C3%A8de%20enregistrerait%20la%20valeur%20de%20%22uname%22%20dans%20la%20valeur%20de%20la%20ligne%201%20pour%20la%20colonne%20%22user%22%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-80045%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80045%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJ'ai%20besoin%20d'obtenir%20le%20nom%20d'utilisateur%20de%20l'ordinateur%20et%20de%20le%20stocker%20dans%20une%20colonne%20d'une%20table%20de%20donn%C3%A9es.%20J'utilise%20le%20script%20suivant%20-%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Euname%20%3D%20Obtenir%20la%20variable%20d'environnement(%20%22NOMORDINATEUR%22%20)%3B%3CBR%20%2F%3E%20dt%3Auser%20%3D%20uname%3B%3C%2FP%3E%3CP%3Eo%C3%B9%20dt%20est%20la%20table%20de%20donn%C3%A9es%20et%20user%20est%20le%20nom%20de%20la%20colonne.%3C%2FP%3E%3CP%3EMais%20j'obtiens%20l'erreur%20suivante%20-%3C%2FP%3E%3CP%3E%22Impossible%20de%20d%C3%A9finir%20la%20valeur%20de%20la%20colonne%20'utilisateur'%20car%20le%20num%C3%A9ro%20de%20ligne%20(-1)%20n'est%20pas%20valide.%22%3C%2FP%3E%3CP%3EQuelqu'un%20peut-il%20me%20dire%20ce%20qui%20ne%20va%20pas%20ici%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3474%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3474%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CP%3Emerci%2C%20la%20syntaxe%20dans%20JMP12%20est%20en%20fait%26nbsp%3B%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EObtenir%20la%20variable%20d'environnement(%22Nom%20de%20l'ordinateur%22)%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3473%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3473%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJ'ai%20besoin%20de%20quelque%20chose%20qui%20ne%20peut%20pas%20%C3%AAtre%20pirat%C3%A9%20par%20quelque%20chose%20d'aussi%20simple%20que%20de%20d%C3%A9finir%20la%20variable%20d'environnement.Merci%20JohnP%20pour%20les%20deux%20solutions!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3472%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3472%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJMP%2010%20prend%20directement%20en%20charge%20cette%20requ%C3%AAte%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EObtenir%20la%20variable%20d'environnement%20(%22Nom%20de%20l'ordinateur%22)%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EMeilleur%2C%3C%2FP%3E%3CP%3E-Mat%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3471%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3471%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ELe%20message%20d'origine%20posait%20%C3%A9galement%20des%20questions%20sur%20le%20nom%20de%20l'ordinateur.%20Pour%20obtenir%20le%20nom%20de%20l'ordinateur%2C%20utilisez%20Kernel32.dll%20et%20le%20nom%20de%20la%20m%C3%A9thode%2C%20GetComputerNameA().%20Il%20ressemblera%20donc%20%C3%A0%20ceci%20%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%3D%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20Charger%20la%20DLL%3C%2FSPAN%3E%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22Kernel32.dll%22%3C%2FSPAN%3E%20)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20FonctionDeclare(%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22ObtenirNomOrdinateurA%22%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EConvention(%20STDCALL%20)%2C%3C%2FP%3E%3CP%3EAlias%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22Obtenir%20le%20nom%20de%20l'ordinateur%22%3C%2FSPAN%3E%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(%20AnsiString%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22Nom%20de%20l'ordinateur%22%3C%2FSPAN%3E%20%2C%20sortir%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(UInt64%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22longueur%22%3C%2FSPAN%3E%20%2C%20mise%20%C3%A0%20jour%20)%2C%3C%2FP%3E%3CP%3ERenvoie%20(UInt32)%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3Enom%20%3D%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22%20%22%3C%2FSPAN%3E%20%3B%3C%2FP%3E%3CP%3Eunlen%20%3D%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20longueur%3C%2FSPAN%3E%20(nom)%3B%3C%2FP%3E%3CP%3Eresult%20%3D%20dll%20%26lt%3B%26lt%3B%20GetComputerName(name%2C%20unlen)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Emontrer%3C%2FSPAN%3E%20(nom)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20D%C3%A9chargerDLL()%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EJeanP%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3470%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3470%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJeanP%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EMerci%20beaucoup!C'est%20exactement%20ce%20que%20je%20recherche.Je%20ne%20peux%20pas%20marquer%20cela%20comme%20la%20bonne%20r%C3%A9ponse%20car%20je%20n'ai%20pas%20commenc%C3%A9%20ce%20fil.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20__jive_emoticon_name%3D%22cool%22%20__jive_macro_name%3D%22emoticon%22%20class%3D%22jive_macro%20jive_macro_emoticon%20jive_emote%22%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2F5.0.2%2Fimages%2Femoticons%2Fcool.gif%22%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3469%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3469%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EVoici%20quelques%20JSL%20que%20j'ai%20%C3%A9crits%20pour%20obtenir%20le%20nom%20d'utilisateur%20du%20syst%C3%A8me.%20Cela%20a%20fonctionn%C3%A9%20dans%20JMP%2010%2C%20fonctionnant%20sous%20Windows%207.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%3D%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20Charger%20la%20DLL%3C%2FSPAN%3E%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22mpr.dll%22%3C%2FSPAN%3E%20)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20FonctionDeclare(%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22WNetGetUserA%22%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EConvention(%20STDCALL%20)%2C%3C%2FP%3E%3CP%3EAlias%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22GetUserName%22%3C%2FSPAN%3E%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(UInt8%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22format%22%3C%2FSPAN%3E%20%2C%20saisir%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(%20AnsiString%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22nom%20d'utilisateur%22%3C%2FSPAN%3E%20%2C%20sortir%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(UInt64%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22longueur%22%3C%2FSPAN%3E%20%2C%20mise%20%C3%A0%20jour%20)%2C%3C%2FP%3E%3CP%3ERenvoie%20(UInt32)%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3Enom%20d'utilisateur%20%3D%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22%20%22%3C%2FSPAN%3E%20%3B%3C%2FP%3E%3CP%3Eunlen%20%3D%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20longueur%3C%2FSPAN%3E%20(nom%20d'utilisateur)%3B%3C%2FP%3E%3CP%3Er%C3%A9sultat%20%3D%20dll%20%26lt%3B%26lt%3B%20GetUserName(%3CSPAN%20style%3D%22color%3A%20%23008000%3B%22%3E%200%3C%2FSPAN%3E%20%2C%20nom%20d'utilisateur%2C%20unlen)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Emontrer%3C%2FSPAN%3E%20(nom%20d'utilisateur)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20D%C3%A9chargerDLL()%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ETout%20d'abord%2C%20vous%20devez%20charger%20la%20DLL%20syst%C3%A8me.%20Je%20n'ai%20pas%20eu%20de%20chance%20avec%20Advapi32.dll.%20Mais%20j'ai%20trouv%C3%A9%20ce%20dont%20j'avais%20besoin%20avec%20mpr.dll.%20Notez%20que%20je%20n'ai%20pas%20eu%20besoin%20de%20sp%C3%A9cifier%20un%20chemin%20d'acc%C3%A8s%20%C3%A0%20la%20DLL%20puisqu'il%20se%20trouvait%20sur%20mon%20chemin%20syst%C3%A8me.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%3D%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20Charger%20la%20DLL%3C%2FSPAN%3E%20(%22mpr.dll%22)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EEnsuite%2C%20vous%20devez%20d%C3%A9clarer%20toute%20m%C3%A9thode%20que%20vous%20allez%20appeler%20dans%20la%20DLL.%20La%20m%C3%A9thode%20que%20je%20veux%20utiliser%20s'appelle%20en%20fait%20WNetGetUserA()%2C%20mais%20en%20d%C3%A9finissant%20un%20alias%2C%20je%20peux%20simplement%20l'appeler%20en%20utilisant%20GetUserName().%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20FonctionDeclare(%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22WNetGetUserA%22%3C%2FSPAN%3E%20%2C%3C%2FP%3E%3CP%3EConvention(%20STDCALL%20)%2C%3C%2FP%3E%3CP%3EAlias%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22GetUserName%22%3C%2FSPAN%3E%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(UInt8%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22format%22%3C%2FSPAN%3E%20%2C%20saisir%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(%20AnsiString%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22nom%20d'utilisateur%22%3C%2FSPAN%3E%20%2C%20sortir%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(UInt64%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22longueur%22%3C%2FSPAN%3E%20%2C%20mise%20%C3%A0%20jour%20)%2C%3C%2FP%3E%3CP%3ERenvoie%20(UInt32)%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EMaintenant%2C%20je%20veux%20d%C3%A9finir%20les%20variables%20que%20je%20vais%20passer%20en%20arguments.%20Je%20cr%C3%A9e%20un%20nom%20d'utilisateur%20et%20l'initialise%20avec%20des%20blancs.%20Ensuite%2C%20j'utilise%20la%20fonction%20length()%20dans%20JMP%20pour%20obtenir%20la%20longueur%20actuelle%20du%20tampon%20que%20je%20viens%20de%20cr%C3%A9er.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Enom%20d'utilisateur%20%3D%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22%20%22%3C%2FSPAN%3E%20%3B%3C%2FP%3E%3CP%3Eunlen%20%3D%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20longueur%3C%2FSPAN%3E%20(nom%20d'utilisateur)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EMaintenant%2C%20je%20peux%20appeler%20la%20fonction.%20Notez%20que%20le%20premier%20argument%20est%20une%20entr%C3%A9e%20uniquement%2C%20donc%20j'utilise%20simplement%20une%20constante%20au%20lieu%20de%20d%C3%A9finir%20une%20variable.%20Ensuite%2C%20la%20commande%20show()%20affiche%20mon%20nom%20d'utilisateur%20apr%C3%A8s%20avoir%20pass%C3%A9%20l'appel.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Er%C3%A9sultat%20%3D%20dll%20%26lt%3B%26lt%3B%20GetUserName(%3CSPAN%20style%3D%22color%3A%20%23008000%3B%22%3E%200%3C%2FSPAN%3E%20%2C%20nom%20d'utilisateur%2C%20unlen)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Emontrer%3C%2FSPAN%3E%20(nom%20d'utilisateur)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EEnfin%2C%20j'ai%20fini%20donc%20je%20nettoie.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20D%C3%A9chargerDLL()%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EJ'esp%C3%A8re%20que%20cela%20fonctionne%20pour%20vous.%20Si%20vous%20trouvez%20une%20meilleure%20m%C3%A9thode%2C%20veuillez%20nous%20en%20informer.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ESoit%20dit%20en%20passant%2C%20l'utilisation%20de%20loadDLL%20ne%20fonctionne%20que%20sous%20Windows.%20Il%20n'est%20pas%20pris%20en%20charge%20sur%20le%20Mac.%20Pour%20cette%20raison%2C%20je%20fais%20une%20v%C3%A9rification%20en%20haut%20de%20mon%20script.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3ENoms%20par%20d%C3%A9faut%20ici%3C%2FSPAN%3E%20(%3CSPAN%20style%3D%22color%3A%20%23008000%3B%22%3E%201%3C%2FSPAN%3E%20)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3ESi%3C%2FSPAN%3E%20(%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20L'h%C3%B4te%20est%3C%2FSPAN%3E%20(%20Mac%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EImprimer%3C%2FSPAN%3E%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22D%C3%A9sol%C3%A9%2C%20ce%20script%20n'est%20pas%20pris%20en%20charge%20sur%20Mac.%22%3C%2FSPAN%3E%20)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArr%C3%AAt%3C%2FSPAN%3E%20()%3B%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAppr%C3%A9cier%2C%3C%2FP%3E%3CP%3EJeanP%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3468%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3468%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EQuelqu'un%20peut-il%20m'aider%20avec%20la%20syntaxe%20pour%20appeler%20une%20DLL%26nbsp%3B%3FJe%20souhaite%20obtenir%20le%20nom%20d'utilisateur%20de%20l'utilisateur%20%C3%A0%20l'aide%20de%20la%20fonction%20GetUserName%20de%20l'API%20Windows.Je%20ne%20veux%20pas%20rechercher%20la%20variable%20d'environnement%20username%20car%20elle%20peut%20%C3%AAtre%20usurp%C3%A9e.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAdvapi32.dll%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EBOOL%20WINAPI%20GetNomUtilisateur(%3C%2FP%3E%3CP%3E_Out_%20LPTSTR%20lpBuffer%2C%3C%2FP%3E%3CP%3E_Inout_%20LPDWORD%20lpnSize%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EMerci!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3467%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3467%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ESalut%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%20En%20supposant%20que%20Windows%20XP%20et%20JMP%208%20permettent%20de%20r%C3%A9cup%C3%A9rer%20les%20variables%20Windoz%20via%20la%20commande%20LoadDLL%20-%20(%C3%A9galement%20avec%20JMP%209%20si%20l'on%20souhaite%20r%C3%A9cup%C3%A9rer%20toutes%20les%20variables%20ENV).%20%3CBR%20%2F%3E%3CBR%20%2F%3EL'exemple%20ci-dessous%20utilise%20la%20fonction%20de%20fen%C3%AAtre%20%22GetEnvironmentStrings%22%20pour%20r%C3%A9cup%C3%A9rer%20toutes%20les%20variables%20d'environnement%20globales%20(y%20compris%20COMPUTERNAME)%20et%20pour%20les%20chargements%20amusants%2C%20puis%20dans%20une%20table%20de%20donn%C3%A9es%20et%20un%20tableau.%3CBR%20%2F%3E%3CBR%20%2F%3E%20voir%3A%3CBR%20%2F%3E%20%3CA%20href%3D%22http%3A%2F%2Fwww.nesug.org%2FProceedings%2Fnesug10%2Fad%2Fad04.pdf%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.nesug.org%2FProceedings%2Fnesug10%2Fad%2Fad04.pdf%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%20Cordialement%2C%3CBR%20%2F%3E%20-Mat%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3466%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3466%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ESalut%2C%3CBR%20%2F%3E%3CBR%20%2F%3E%20j'utilise%20jmp%208%20existe-t-il%20une%20fonction%20similaire%20qui%20r%C3%A9cup%C3%A8re%20le%20nom%20de%20l'ordinateur%3CBR%20%2F%3E%3CBR%20%2F%3E%20r%C3%A9servoirs%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3465%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3465%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ESalut%20Pneil%20%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%20Sur%20Windose%2C%20depuis%20le%20menu%20d%C3%A9marrer%2C%20ex%C3%A9cutez%2C%20cmd%20ouvre%20une%20fen%C3%AAtre%20DOS.%20%C3%80%20partir%20de%20l'invite%2C%20tapez%20%22set%22%20pour%20obtenir%20la%20liste%20des%20variables%20d'environnement%20actives.%3CBR%20%2F%3E%3CBR%20%2F%3E%20Aussi%20-%20faites%20un%20clic%20droit%20sur%20l'ic%C3%B4ne%20Mon%20ordinateur%20sur%20le%20bureau%20-%20s%C3%A9lectionnez%20le%20bouton%20des%20variables%20d'environnement%20de%20l'onglet%20Avanc%C3%A9%20pr%C3%A8s%20du%20bas.%3CBR%20%2F%3E%3CBR%20%2F%3E%20JMP%209%20inclut%20la%20fonction%20pratique%20permettant%20de%20r%C3%A9cup%C3%A9rer%20l'un%20de%20ces%20%C3%A9l%C3%A9ments%20dans%20l'environnement%26nbsp%3B%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%20cname%20%3D%20Obtenir%20la%20variable%20d'environnement(%20%22NOMORDINATEUR%22%20)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%20et%20on%20peut%20cr%C3%A9er%20une%20branche%20en%20cons%C3%A9quence%20en%20fonction%20de%20la%20valeur%20renvoy%C3%A9e%20%C3%A0%20partir%20de%20l%C3%A0.%3CBR%20%2F%3E%3CBR%20%2F%3E%20Cordialement%2C%3CBR%20%2F%3E%20-Mat%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-753036%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%20%3A%20nom%20de%20l'ordinateur%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-753036%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ECela%20a%20fonctionn%C3%A9%20pour%20moi%20pour%20obtenir%20le%20nom%20d'utilisateur%20actuel%20sous%20Windows%26nbsp%3B%3A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Euname%20%3D%20Get%20Environment%20Variable(%20%22USERNAME%22%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
pniel
Level I

computer name

Hi jmpers,

I need to build an application in jmp for different users, meaning that different users will have different User Interface.. (it is the same application) I was wondering if is there a way to get user profile? Let say computer name, user name or server name from jmp ? Doing so I can decide which script to open

Tanks

pniel
17 REPLIES 17
pmroz
Super User

Re: computer name

Can someone help me with the syntax for calling a DLL?  I want to get the user's username using the Windows API GetUserName function.  I don't want to look up the username environment variable because that can be spoofed.

Advapi32.dll

BOOL WINAPI GetUserName(

  _Out_    LPTSTR lpBuffer,

  _Inout_  LPDWORD lpnSize

);

Thanks!

JohnPonte
Staff (Retired)

Re: computer name

Here is some JSL that I wrote for getting the username from the system. This worked in JMP 10, running on Windows 7.

dll = Load DLL( "mpr.dll" );

dll << DeclareFunction(

     "WNetGetUserA",

      Convention( STDCALL ),

      Alias ( "GetUserName" ),

      Arg( UInt8, "format", input ),

      Arg( AnsiString, "username", output ),

      Arg( UInt64, "length", update ),

      Returns( UInt32 )

);

username = "                                                  ";

unlen = length(username);

result = dll << GetUserName(0, username, unlen);

show(username);

dll << UnloadDLL();

First, you need to load the system DLL. I didn't have any luck with Advapi32.dll. But I found what I needed with mpr.dll. Notice I didn't need to specify a path to the DLL since it was on my system path.

dll = Load DLL("mpr.dll");

Next, you need to declare any method that you are going to call in the DLL. The method I want to use is actually called WNetGetUserA(), but by defining an alias, I can simply call it using GetUserName().

dll << DeclareFunction(

      "WNetGetUserA",

      Convention( STDCALL ),

      Alias ( "GetUserName" ),

      Arg( UInt8, "format", input ),

      Arg( AnsiString, "username", output ),

      Arg( UInt64, "length", update ),

      Returns( UInt32 )

);

Now I want to define the variables that I am going to pass in as arguments. I create a username and initialize it to blanks. Then I use the length() function in JMP to get the current length of the buffer I just created.

username = "                                                  " ;

unlen = length(username);

Now I can call the function. Notice the first argument is input only, so I just use a constant instead of defining a variable. Then the show() command shows my username after making the call.

result = dll << GetUserName(0, username, unlen);

show(username);

Finally, I am done so I clean up.

dll << UnloadDLL();

I hope this works for you. If you come up with a better way, please let us know.

By the way, using loadDLL only works on Windows. It isn't supported on the Mac. For that reason I do a check at the top of my script.

Names Default To Here( 1 );

If( Host is( Mac ),

     Print( "Sorry, this script is not supported on Mac." );

     Stop();

);

Enjoy,

JohnP

pmroz
Super User

Re: computer name

JohnP,

Thanks so much!  That's exactly what I'm looking for.  Can't mark this as the correct answer because I didn't start this thread.

JohnPonte
Staff (Retired)

Re: computer name

The original post also asked about the computer name. To get the computer name, use Kernel32.dll and the method name, GetComputerNameA(). So it will look like this:

dll = Load DLL( "Kernel32.dll" );

dll << DeclareFunction(

     "GetComputerNameA",

      Convention( STDCALL ),

      Alias ( "GetComputerName" ),

      Arg( AnsiString, "computername", output ),

      Arg( UInt64, "length", update ),

      Returns( UInt32 )

);

name = "                                                  ";

unlen = length(name);

result = dll << GetComputerName(name, unlen);

show(name);

dll << UnloadDLL();

JohnP

mattflynn
Level III

Re: computer name

JMP 10 supports this query directly

Get Enviromental Variable("Computername")

Best,

-Matt

pmroz
Super User

Re: computer name

I need something that can't be hacked by something as simple as setting the environment variable.  Thanks JohnP for both solutions!

jmpbeginner
Level III

Re: computer name

thanks, syntax in JMP12 is actually:

Get Environment Variable("Computername");

Byron_JMP
Staff

Re: computer name

For Mac OS

 

Try this:

If( Host is( "Mac" ),username=Get Environment Variable( "USER" );
	stamp="Test "||username||", "||char(today());
);
JMP Systems Engineer, Health and Life Sciences (Pharma)