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%3Enombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3464%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EHola%20jmpers%2C%3CBR%20%2F%3E%3CBR%20%2F%3E%20Necesito%20crear%20una%20aplicaci%C3%B3n%20en%20jmp%20para%20diferentes%20usuarios%2C%20lo%20que%20significa%20que%20diferentes%20usuarios%20tendr%C3%A1n%20una%20interfaz%20de%20usuario%20diferente.%20(es%20la%20misma%20aplicaci%C3%B3n)%20Me%20preguntaba%20si%20hay%20alguna%20forma%20de%20obtener%20el%20perfil%20de%20usuario.%20Digamos%20el%20nombre%20de%20la%20computadora%2C%20el%20nombre%20de%20usuario%20o%20el%20nombre%20del%20servidor%20de%20jmp.%20Al%20hacerlo%2C%20puedo%20decidir%20qu%C3%A9%20script%20abrir.%3CBR%20%2F%3E%3CBR%20%2F%3E%20tanques%3CBR%20%2F%3E%3CBR%20%2F%3E%20paniel%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-84899%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20nombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84899%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EPara%20sistema%20operativo%20Mac%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPrueba%20esto%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%20nombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80209%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%C2%A1Impresionante!%20gracias%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-80192%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20nombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80192%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EPuede%20usar%20un%20For()%20Loop%2C%20o%20puede%20hacer%20algo%20como%20lo%20siguiente%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%20nombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80117%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EFunciona.%20Pero%2C%20%C2%BFqu%C3%A9%20pasa%20si%20tengo%2010%20filas%20y%20quiero%20tener%20un%20nombre%20en%20todas%20las%20filas%3F%3C%2FP%3E%3CP%3E%C2%BFUso%20un%20bucle%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%20nombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80054%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EDebe%20decirle%20a%20JMP%20en%20qu%C3%A9%20fila%20de%20la%20tabla%20de%20datos%20para%20la%20columna%20Usuario%20desea%20guardar%20el%20valor.%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%3ELo%20anterior%20guardar%C3%ADa%20el%20valor%20de%20%22uname%22%20en%20el%20valor%20de%20la%20fila%201%20para%20la%20columna%20%22usuario%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%20nombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80045%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ENecesito%20obtener%20el%20nombre%20de%20usuario%20de%20la%20computadora%20y%20almacenarlo%20en%20una%20columna%20de%20una%20tabla%20de%20datos.%20Estoy%20usando%20el%20siguiente%20script%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Euname%20%3D%20Obtener%20variable%20de%20entorno%20(%22COMPUTERNAME%22)%3B%3CBR%20%2F%3E%20dt%3Ausuario%20%3D%20uname%3B%3C%2FP%3E%3CP%3Edonde%20dt%20es%20la%20tabla%20de%20datos%20y%20usuario%20es%20el%20nombre%20de%20la%20columna.%3C%2FP%3E%3CP%3EPero%20me%20sale%20el%20siguiente%20error%20-%3C%2FP%3E%3CP%3E%22No%20se%20puede%20establecer%20el%20valor%20para%20la%20columna%20'usuario'%20porque%20el%20n%C3%BAmero%20de%20fila%20(-1)%20no%20es%20v%C3%A1lido%22.%3C%2FP%3E%3CP%3E%C2%BFAlguien%20puede%20decirme%20qu%C3%A9%20est%C3%A1%20mal%20aqu%C3%AD%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%20nombre%20de%20la%20computadora%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%3Egracias%2C%20la%20sintaxis%20en%20JMP12%20es%20en%20realidad%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EObtener%20variable%20de%20entorno%20(%22Nombre%20de%20la%20computadora%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%20nombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3473%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ENecesito%20algo%20que%20no%20pueda%20ser%20pirateado%20por%20algo%20tan%20simple%20como%20configurar%20la%20variable%20de%20entorno.%C2%A1Gracias%20JohnP%20por%20ambas%20soluciones!%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%20nombre%20de%20la%20computadora%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%20admite%20esta%20consulta%20directamente%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EObtener%20variable%20ambiental%20(%22Nombre%20de%20la%20computadora%22)%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EMejor%2C%3C%2FP%3E%3CP%3E-Mate%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%20nombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3471%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ELa%20publicaci%C3%B3n%20original%20tambi%C3%A9n%20preguntaba%20sobre%20el%20nombre%20de%20la%20computadora.%20Para%20obtener%20el%20nombre%20de%20la%20computadora%2C%20use%20Kernel32.dll%20y%20el%20nombre%20del%20m%C3%A9todo%2C%20GetComputerNameA().%20Entonces%20se%20ver%C3%A1%20as%C3%AD%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%3D%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20Cargar%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%20DeclararFunci%C3%B3n(%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22ObtenerNombreDeEquipoA%22%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EConvenci%C3%B3n%20(STDCALL)%2C%3C%2FP%3E%3CP%3EAlias%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22ObtenerNombreDeEquipo%22%3C%2FSPAN%3E%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArgentina%3C%2FSPAN%3E%20(AnsiString%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22nombre%20de%20la%20computadora%22%3C%2FSPAN%3E%20%2C%20producci%C3%B3n%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArgentina%3C%2FSPAN%3E%20(UInt64%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22longitud%22%3C%2FSPAN%3E%20%2C%20actualizar%20)%2C%3C%2FP%3E%3CP%3EDevoluciones%20(UInt32)%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3Enombre%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%20longitud%3C%2FSPAN%3E%20(nombre)%3B%3C%2FP%3E%3CP%3Eresultado%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%3Eespect%C3%A1culo%3C%2FSPAN%3E%20(nombre)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20DescargarDLL()%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EJuanP%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%20nombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3470%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJuan%20P%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%C2%A1Muchas%20gracias!Eso%20es%20exactamente%20lo%20que%20estoy%20buscando.No%20puedo%20marcar%20esto%20como%20la%20respuesta%20correcta%20porque%20no%20comenc%C3%A9%20este%20hilo.%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%20nombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3469%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EAqu%C3%AD%20hay%20algunos%20JSL%20que%20escrib%C3%AD%20para%20obtener%20el%20nombre%20de%20usuario%20del%20sistema.%20Esto%20funcion%C3%B3%20en%20JMP%2010%2C%20ejecut%C3%A1ndose%20en%20Windows%207.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%3D%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20Cargar%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%20DeclararFunci%C3%B3n(%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%3EConvenci%C3%B3n%20(STDCALL)%2C%3C%2FP%3E%3CP%3EAlias%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22Obtener%20nombre%20de%20usuario%22%3C%2FSPAN%3E%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArgentina%3C%2FSPAN%3E%20(UInt8%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22formato%22%3C%2FSPAN%3E%20%2C%20aporte%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArgentina%3C%2FSPAN%3E%20(AnsiString%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22nombre%20de%20usuario%22%3C%2FSPAN%3E%20%2C%20producci%C3%B3n%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArgentina%3C%2FSPAN%3E%20(UInt64%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22longitud%22%3C%2FSPAN%3E%20%2C%20actualizar%20)%2C%3C%2FP%3E%3CP%3EDevoluciones%20(UInt32)%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3Enombre%20de%20usuario%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%20longitud%3C%2FSPAN%3E%20(nombre%20de%20usuario)%3B%3C%2FP%3E%3CP%3Eresultado%20%3D%20dll%20%26lt%3B%26lt%3B%20ObtenerNombreUsuario(%3CSPAN%20style%3D%22color%3A%20%23008000%3B%22%3E%200%3C%2FSPAN%3E%20%2C%20nombre%20de%20usuario%2C%20unlen)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Eespect%C3%A1culo%3C%2FSPAN%3E%20(nombre%20de%20usuario)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20DescargarDLL()%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EPrimero%2C%20debe%20cargar%20la%20DLL%20del%20sistema.%20No%20tuve%20suerte%20con%20Advapi32.dll.%20Pero%20encontr%C3%A9%20lo%20que%20necesitaba%20con%20mpr.dll.%20Tenga%20en%20cuenta%20que%20no%20necesitaba%20especificar%20una%20ruta%20a%20la%20DLL%20ya%20que%20estaba%20en%20la%20ruta%20de%20mi%20sistema.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%3D%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20Cargar%20DLL%3C%2FSPAN%3E%20(%22mpr.dll%22)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EA%20continuaci%C3%B3n%2C%20debe%20declarar%20cualquier%20m%C3%A9todo%20al%20que%20vaya%20a%20llamar%20en%20la%20DLL.%20El%20m%C3%A9todo%20que%20quiero%20usar%20en%20realidad%20se%20llama%20WNetGetUserA()%2C%20pero%20al%20definir%20un%20alias%2C%20puedo%20simplemente%20llamarlo%20usando%20GetUserName().%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20DeclararFunci%C3%B3n(%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%3EConvenci%C3%B3n%20(STDCALL)%2C%3C%2FP%3E%3CP%3EAlias%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22Obtener%20nombre%20de%20usuario%22%3C%2FSPAN%3E%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArgentina%3C%2FSPAN%3E%20(UInt8%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22formato%22%3C%2FSPAN%3E%20%2C%20aporte%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArgentina%3C%2FSPAN%3E%20(AnsiString%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22nombre%20de%20usuario%22%3C%2FSPAN%3E%20%2C%20producci%C3%B3n%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArgentina%3C%2FSPAN%3E%20(UInt64%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22longitud%22%3C%2FSPAN%3E%20%2C%20actualizar%20)%2C%3C%2FP%3E%3CP%3EDevoluciones%20(UInt32)%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAhora%20quiero%20definir%20las%20variables%20que%20voy%20a%20pasar%20como%20argumentos.%20Creo%20un%20nombre%20de%20usuario%20y%20lo%20inicializo%20en%20espacios%20en%20blanco.%20Luego%20uso%20la%20funci%C3%B3n%20length()%20en%20JMP%20para%20obtener%20la%20longitud%20actual%20del%20b%C3%BAfer%20que%20acabo%20de%20crear.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Enombre%20de%20usuario%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%20longitud%3C%2FSPAN%3E%20(nombre%20de%20usuario)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAhora%20puedo%20llamar%20a%20la%20funci%C3%B3n.%20Observe%20que%20el%20primer%20argumento%20es%20solo%20de%20entrada%2C%20por%20lo%20que%20solo%20uso%20una%20constante%20en%20lugar%20de%20definir%20una%20variable.%20Luego%2C%20el%20comando%20show%20()%20muestra%20mi%20nombre%20de%20usuario%20despu%C3%A9s%20de%20realizar%20la%20llamada.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Eresultado%20%3D%20dll%20%26lt%3B%26lt%3B%20ObtenerNombreUsuario(%3CSPAN%20style%3D%22color%3A%20%23008000%3B%22%3E%200%3C%2FSPAN%3E%20%2C%20nombre%20de%20usuario%2C%20unlen)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Eespect%C3%A1culo%3C%2FSPAN%3E%20(nombre%20de%20usuario)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EFinalmente%2C%20he%20terminado%2C%20as%C3%AD%20que%20limpio.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20DescargarDLL()%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EEspero%20que%20esto%20funcione%20para%20ti.%20Si%20se%20te%20ocurre%20una%20forma%20mejor%2C%20h%C3%A1znoslo%20saber.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EPor%20cierto%2C%20usar%20loadDLL%20solo%20funciona%20en%20Windows.%20No%20es%20compatible%20con%20Mac.%20Por%20esa%20raz%C3%B3n%2C%20hago%20una%20verificaci%C3%B3n%20en%20la%20parte%20superior%20de%20mi%20script.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3ENombres%20predeterminados%20hasta%20aqu%C3%AD%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%20El%20anfitri%C3%B3n%20es%3C%2FSPAN%3E%20(%20Mac%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EImprimir%3C%2FSPAN%3E%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22Lo%20sentimos%2C%20esta%20secuencia%20de%20comandos%20no%20es%20compatible%20con%20Mac%22.%3C%2FSPAN%3E%20)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EDetener%3C%2FSPAN%3E%20()%3B%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EDisfrutar%2C%3C%2FP%3E%3CP%3EJuanP%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%20nombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3468%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%C2%BFPuede%20alguien%20ayudarme%20con%20la%20sintaxis%20para%20llamar%20a%20una%20DLL%3FQuiero%20obtener%20el%20nombre%20de%20usuario%20del%20usuario%20mediante%20la%20funci%C3%B3n%20GetUserName%20de%20la%20API%20de%20Windows.No%20quiero%20buscar%20la%20variable%20de%20entorno%20del%20nombre%20de%20usuario%20porque%20se%20puede%20falsificar.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAdvapi32.dll%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EBOOL%20WINAPI%20ObtenerNombreUsuario(%3C%2FP%3E%3CP%3E_Salida_%20LPTSTR%20lpBuffer%2C%3C%2FP%3E%3CP%3E_Entrada_%20LPDWORD%20lpnSize%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%C2%A1Gracias!%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%20nombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3467%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EHola%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%20Suponiendo%20que%20Windows%20XP%20y%20JMP%208%20se%20pueden%20recuperar%20las%20variables%20de%20Windoz%20a%20trav%C3%A9s%20del%20comando%20LoadDLL%20(tambi%C3%A9n%20con%20JMP%209%20si%20se%20quiere%20recuperar%20todas%20las%20variables%20ENV).%20%3CBR%20%2F%3E%3CBR%20%2F%3EEl%20siguiente%20ejemplo%20utiliza%20la%20funci%C3%B3n%20de%20Windows%20%22GetEnvironmentStrings%22%20para%20recuperar%20todas%20las%20variables%20ambientales%20globales%20(incluido%20COMPUTERNAME)%20y%2C%20por%20diversi%C3%B3n%2C%20las%20carga%20en%20una%20tabla%20de%20datos%20y%20una%20matriz.%3CBR%20%2F%3E%3CBR%20%2F%3E%20ver%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%20Atentamente%2C%3CBR%20%2F%3E%20-Mate%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%20nombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3466%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EHola%2C%3CBR%20%2F%3E%3CBR%20%2F%3E%20estoy%20usando%20jmp%208%2C%20%C2%BFhay%20una%20funci%C3%B3n%20similar%20que%20recupere%20el%20nombre%20de%20la%20computadora%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%20tanques%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3465%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20nombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3465%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EHola%20Pneil%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%20En%20Windose%2C%20desde%20el%20men%C3%BA%20de%20inicio%2C%20ejecutar%2C%20cmd%20abre%20una%20ventana%20de%20DOS.%20Desde%20el%20indicador%2C%20escriba%20%22set%22%20para%20la%20lista%20de%20variables%20ambientales%20activas.%3CBR%20%2F%3E%3CBR%20%2F%3E%20Adem%C3%A1s%2C%20haga%20clic%20con%20el%20bot%C3%B3n%20derecho%20en%20el%20%C3%ADcono%20Mi%20PC%20en%20el%20escritorio%2C%20seleccione%20el%20bot%C3%B3n%20de%20variables%20ambientales%20de%20la%20pesta%C3%B1a%20Avanzado%20cerca%20de%20la%20parte%20inferior.%3CBR%20%2F%3E%3CBR%20%2F%3E%20JMP%209%20incluye%20la%20pr%C3%A1ctica%20funci%C3%B3n%20para%20recuperar%20cualquiera%20de%20estos%20del%20entorno%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%20cname%20%3D%20Obtener%20variable%20de%20entorno%20(%22COMPUTERNAME%22)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%20y%20uno%20puede%20bifurcarse%20en%20consecuencia%20en%20funci%C3%B3n%20del%20valor%20devuelto%20desde%20all%C3%AD.%3CBR%20%2F%3E%3CBR%20%2F%3E%20Atentamente%2C%3CBR%20%2F%3E%20-Mate%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-753036%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20nombre%20de%20la%20computadora%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-753036%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EEsto%20funcion%C3%B3%20para%20m%C3%AD%20para%20obtener%20el%20nombre%20de%20usuario%20actual%20en%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)