cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-3464%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3Enome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3464%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ECiao%20jmpers%2C%3CBR%20%2F%3E%3CBR%20%2F%3E%20Devo%20creare%20un'applicazione%20in%20jmp%20per%20utenti%20diversi%2C%20il%20che%20significa%20che%20utenti%20diversi%20avranno%20un'interfaccia%20utente%20diversa.%20(%C3%A8%20la%20stessa%20applicazione)%20Mi%20chiedevo%20se%20c'%C3%A8%20un%20modo%20per%20ottenere%20il%20profilo%20utente%3F%20Diciamo%20nome%20computer%2C%20nome%20utente%20o%20nome%20server%20da%20jmp%3F%20Cos%C3%AC%20facendo%20posso%20decidere%20quale%20script%20aprire%3CBR%20%2F%3E%3CBR%20%2F%3E%20Carri%20armati%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%3A%20nome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84899%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EPer%20sistema%20operativo%20Mac%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EProva%20questo%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%3A%20nome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80209%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EEccezionale!%20Grazie%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-80192%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20nome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80192%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EPuoi%20usare%20un%20ciclo%20For()%20oppure%20puoi%20fare%20qualcosa%20di%20simile%20al%20seguente%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%3A%20nome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80117%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EFunziona.%20Ma%20cosa%20succede%20se%20ho%2010%20righe%20e%20voglio%20avere%20uname%20in%20tutte%20le%20righe%3F%3C%2FP%3E%3CP%3EUso%20un%20ciclo%20for%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%3A%20nome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80054%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EDevi%20indicare%20a%20JMP%20in%20quale%20riga%20della%20tabella%20dati%20per%20la%20colonna%20Utente%20desideri%20salvare%20il%20valore.%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%3EQuanto%20sopra%20salverebbe%20il%20valore%20di%20%22uname%22%20nel%20valore%20della%20riga%201%20per%20la%20colonna%20%22utente%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%3A%20nome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80045%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EDevo%20ottenere%20il%20nome%20utente%20del%20computer%20e%20memorizzarlo%20in%20una%20colonna%20di%20un%20datatable.%20Sto%20usando%20il%20seguente%20script%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Euname%20%3D%20Ottieni%20variabile%20d'ambiente(%20%22NOMECOMPUTER%22%20)%3B%3CBR%20%2F%3E%20dt%3Autente%20%3D%20uname%3B%3C%2FP%3E%3CP%3Edove%20dt%20%C3%A8%20la%20tabella%20dati%20e%20user%20%C3%A8%20il%20nome%20della%20colonna.%3C%2FP%3E%3CP%3EMa%20ottengo%20il%20seguente%20errore%3A%3C%2FP%3E%3CP%3E%22Impossibile%20impostare%20il%20valore%20per%20la%20colonna%20'utente'%20perch%C3%A9%20il%20numero%20di%20riga%20(-1)%20non%20%C3%A8%20valido.%22%3C%2FP%3E%3CP%3EQualcuno%20pu%C3%B2%20dirmi%20cosa%20c'%C3%A8%20che%20non%20va%20qui%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%3A%20nome%20del%20computer%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%3Egrazie%2C%20la%20sintassi%20in%20JMP12%20%C3%A8%20in%20realt%C3%A0%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EOttieni%20variabile%20d'ambiente%20(%22Nome%20computer%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%3A%20nome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3473%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHo%20bisogno%20di%20qualcosa%20che%20non%20possa%20essere%20violato%20da%20qualcosa%20di%20semplice%20come%20impostare%20la%20variabile%20d'ambiente.Grazie%20JohnP%20per%20entrambe%20le%20soluzioni!%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%3A%20nome%20del%20computer%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%20supporta%20direttamente%20questa%20query%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EOttieni%20variabile%20d'ambiente%20(%22Nome%20computer%22)%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EMigliore%2C%3C%2FP%3E%3CP%3E-Opaco%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%3A%20nome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3471%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EIl%20post%20originale%20chiedeva%20anche%20il%20nome%20del%20computer.%20Per%20ottenere%20il%20nome%20del%20computer%2C%20utilizzare%20Kernel32.dll%20e%20il%20nome%20del%20metodo%2C%20GetComputerNameA().%20Quindi%20sar%C3%A0%20simile%20a%20questo%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%3D%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20Carica%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%3CDICHIARAFUNZIONE%3E%3C%2FDICHIARAFUNZIONE%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22OttieniNomeComputerA%22%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EConvenzione(%20STDCALL%20)%2C%3C%2FP%3E%3CP%3EAlias%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22OttieniNomeComputer%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%22nome%20del%20computer%22%3C%2FSPAN%3E%20%2C%20produzione%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%22lunghezza%22%3C%2FSPAN%3E%20%2C%20aggiornamento%20)%2C%3C%2FP%3E%3CP%3ERestituisce(%20UInt32%20)%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3Enome%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%20lunghezza%3C%2FSPAN%3E%20(nome)%3B%3C%2FP%3E%3CP%3Erisultato%20%3D%20dll%20%26lt%3B%26lt%3B%20GetComputerName(nome%2C%20unlen)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Espettacolo%3C%2FSPAN%3E%20(nome)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20ScaricaDLL()%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EGiovanni%20P%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%3A%20nome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3470%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EGiovanniP%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EGrazie%20mille!%C3%88%20proprio%20quello%20che%20sto%20cercando.Non%20posso%20contrassegnare%20questa%20come%20risposta%20corretta%20perch%C3%A9%20non%20ho%20iniziato%20io%20questa%20discussione.%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%3A%20nome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3469%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EEcco%20alcuni%20JSL%20che%20ho%20scritto%20per%20ottenere%20il%20nome%20utente%20dal%20sistema.%20Funzionava%20in%20JMP%2010%2C%20in%20esecuzione%20su%20Windows%207.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%3D%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20Carica%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%3CDICHIARAFUNZIONE%3E%3C%2FDICHIARAFUNZIONE%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22WNetGetUtenteA%22%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EConvenzione(%20STDCALL%20)%2C%3C%2FP%3E%3CP%3EAlias%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22OttieniNomeUtente%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%22formato%22%3C%2FSPAN%3E%20%2C%20ingresso%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%22nome%20utente%22%3C%2FSPAN%3E%20%2C%20produzione%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%22lunghezza%22%3C%2FSPAN%3E%20%2C%20aggiornamento%20)%2C%3C%2FP%3E%3CP%3ERestituisce(%20UInt32%20)%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3Enome%20utente%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%20lunghezza%3C%2FSPAN%3E%20(nome%20utente)%3B%3C%2FP%3E%3CP%3Erisultato%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%20nome%20utente%2C%20unlen)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Espettacolo%3C%2FSPAN%3E%20(nome%20utente)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20ScaricaDLL()%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EInnanzitutto%2C%20%C3%A8%20necessario%20caricare%20la%20DLL%20di%20sistema.%20Non%20ho%20avuto%20fortuna%20con%20Advapi32.dll.%20Ma%20ho%20trovato%20quello%20che%20mi%20serviva%20con%20mpr.dll.%20Si%20noti%20che%20non%20ho%20bisogno%20di%20specificare%20un%20percorso%20per%20la%20DLL%20poich%C3%A9%20era%20nel%20mio%20percorso%20di%20sistema.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%3D%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20Carica%20DLL%3C%2FSPAN%3E%20(%22mpr.dll%22)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ESuccessivamente%2C%20devi%20dichiarare%20qualsiasi%20metodo%20che%20chiamerai%20nella%20DLL.%20Il%20metodo%20che%20voglio%20usare%20%C3%A8%20in%20realt%C3%A0%20chiamato%20WNetGetUserA()%2C%20ma%20definendo%20un%20alias%2C%20posso%20semplicemente%20chiamarlo%20usando%20GetUserName().%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%26lt%3B%3CDICHIARAFUNZIONE%3E%3C%2FDICHIARAFUNZIONE%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22WNetGetUtenteA%22%3C%2FSPAN%3E%20%2C%3C%2FP%3E%3CP%3EConvenzione(%20STDCALL%20)%2C%3C%2FP%3E%3CP%3EAlias%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22OttieniNomeUtente%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%22formato%22%3C%2FSPAN%3E%20%2C%20ingresso%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%22nome%20utente%22%3C%2FSPAN%3E%20%2C%20produzione%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%22lunghezza%22%3C%2FSPAN%3E%20%2C%20aggiornamento%20)%2C%3C%2FP%3E%3CP%3ERestituisce(%20UInt32%20)%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EOra%20voglio%20definire%20le%20variabili%20che%20passer%C3%B2%20come%20argomenti.%20Creo%20un%20nome%20utente%20e%20lo%20inizializzo%20in%20spazi%20vuoti.%20Quindi%20utilizzo%20la%20funzione%20length()%20in%20JMP%20per%20ottenere%20la%20lunghezza%20corrente%20del%20buffer%20che%20ho%20appena%20creato.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Enome%20utente%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%20lunghezza%3C%2FSPAN%3E%20(nome%20utente)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EOra%20posso%20chiamare%20la%20funzione.%20Si%20noti%20che%20il%20primo%20argomento%20%C3%A8%20solo%20input%2C%20quindi%20utilizzo%20solo%20una%20costante%20invece%20di%20definire%20una%20variabile.%20Quindi%20il%20comando%20show()%20mostra%20il%20mio%20nome%20utente%20dopo%20aver%20effettuato%20la%20chiamata.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Erisultato%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%20nome%20utente%2C%20unlen)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Espettacolo%3C%2FSPAN%3E%20(nome%20utente)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAlla%20fine%2C%20ho%20finito%2C%20quindi%20pulisco.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20ScaricaDLL()%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ESpero%20che%20questo%20funzioni%20per%20te.%20Se%20trovi%20un%20modo%20migliore%2C%20faccelo%20sapere.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EA%20proposito%2C%20l'utilizzo%20di%20loadDLL%20funziona%20solo%20su%20Windows.%20Non%20%C3%A8%20supportato%20su%20Mac.%20Per%20questo%20motivo%20faccio%20un%20controllo%20all'inizio%20del%20mio%20script.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EI%20nomi%20predefiniti%20sono%20qui%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%3ESe%3C%2FSPAN%3E%20(%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20L'ospite%20%C3%A8%3C%2FSPAN%3E%20(%20Mac%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EStampa%3C%2FSPAN%3E%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22Spiacenti%2C%20questo%20script%20non%20%C3%A8%20supportato%20su%20Mac.%22%3C%2FSPAN%3E%20)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EFermare%3C%2FSPAN%3E%20()%3B%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EGodere%2C%3C%2FP%3E%3CP%3EGiovanni%20P%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%3A%20nome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3468%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EQualcuno%20pu%C3%B2%20aiutarmi%20con%20la%20sintassi%20per%20chiamare%20una%20DLL%3FVoglio%20ottenere%20il%20nome%20utente%20dell'utente%20utilizzando%20la%20funzione%20GetUserName%20dell'API%20di%20Windows.Non%20voglio%20cercare%20la%20variabile%20d'ambiente%20del%20nome%20utente%20perch%C3%A9%20pu%C3%B2%20essere%20falsificata.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAdvapi32.dll%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EBOOL%20WINAPI%20GetNomeUtente(%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%3EGrazie!%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%3A%20nome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3467%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ECIAO%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%20Supponendo%20che%20Windows%20XP%20e%20JMP%208%20si%20possano%20recuperare%20le%20variabili%20Windoz%20tramite%20il%20comando%20LoadDLL%20-%20(anche%20con%20JMP%209%20se%20si%20desidera%20recuperare%20tutte%20le%20variabili%20ENV).%20%3CBR%20%2F%3E%3CBR%20%2F%3EL'esempio%20seguente%20utilizza%20la%20funzione%20di%20Windows%20%22GetEnvironmentStrings%22%20per%20recuperare%20tutte%20le%20variabili%20ambientali%20globali%20(incluso%20COMPUTERNAME)%20e%20per%20i%20carichi%20divertenti%20quindi%20in%20una%20tabella%20di%20dati%20e%20in%20un%20array.%3CBR%20%2F%3E%3CBR%20%2F%3E%20Vedere%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%20Distinti%20saluti%2C%3CBR%20%2F%3E%20-Opaco%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%3A%20nome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3466%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ECIAO%2C%3CBR%20%2F%3E%3CBR%20%2F%3E%20sto%20usando%20jmp%208%20c'%C3%A8%20una%20funzione%20simile%20che%20recupera%20il%20nome%20del%20computer%3CBR%20%2F%3E%3CBR%20%2F%3E%20carri%20armati%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3465%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20nome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3465%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ECiao%20Pnel%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%20Su%20Windose%2C%20dal%20menu%20start%2C%20esegui%2C%20cmd%20apre%20una%20finestra%20DOS.%20Dal%20prompt%20digitare%20%22set%22%20per%20l'elenco%20delle%20variabili%20ambientali%20attive.%3CBR%20%2F%3E%3CBR%20%2F%3E%20Inoltre%2C%20fai%20clic%20con%20il%20pulsante%20destro%20del%20mouse%20sull'icona%20Risorse%20del%20computer%20sul%20desktop%2C%20seleziona%20il%20pulsante%20Variabili%20ambientali%20della%20scheda%20Avanzate%20nella%20parte%20inferiore.%3CBR%20%2F%3E%3CBR%20%2F%3E%20JMP%209%20include%20la%20pratica%20funzione%20per%20recuperare%20uno%20qualsiasi%20di%20questi%20dall'ambiente%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%20cname%20%3D%20Ottieni%20variabile%20d'ambiente(%20%22NOMECOMPUTER%22%20)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%20e%20si%20pu%C3%B2%20diramare%20di%20conseguenza%20in%20base%20al%20valore%20restituito%20da%20l%C3%AC.%3CBR%20%2F%3E%3CBR%20%2F%3E%20Distinti%20saluti%2C%3CBR%20%2F%3E%20-Opaco%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-753036%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERi%3A%20nome%20del%20computer%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-753036%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EQuesto%20ha%20funzionato%20per%20me%20per%20ottenere%20il%20nome%20utente%20corrente%20su%20Windows%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)