cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
%3CLINGO-SUB%20id%3D%22lingo-sub-3464%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EComputername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3464%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EHallo%20jmpers%2C%3CBR%20%2F%3E%3CBR%20%2F%3E%20Ich%20muss%20eine%20Anwendung%20in%20jmp%20f%C3%BCr%20verschiedene%20Benutzer%20erstellen%2C%20was%20bedeutet%2C%20dass%20verschiedene%20Benutzer%20unterschiedliche%20Benutzeroberfl%C3%A4chen%20haben.%20(es%20ist%20die%20gleiche%20Anwendung)%20Ich%20habe%20mich%20gefragt%2C%20ob%20es%20eine%20M%C3%B6glichkeit%20gibt%2C%20ein%20Benutzerprofil%20zu%20erhalten%3F%20Sagen%20wir%20Computername%2C%20Benutzername%20oder%20Servername%20von%20jmp%3F%20Dadurch%20kann%20ich%20entscheiden%2C%20welches%20Skript%20ge%C3%B6ffnet%20werden%20soll%3CBR%20%2F%3E%3CBR%20%2F%3E%20Panzer%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%3EBetreff%3A%20Computername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84899%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EF%C3%BCr%20Mac%20OS%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EVersuche%20dies%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%3EBetreff%3A%20Computername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80209%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EEindrucksvoll!%20Danke%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-80192%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Computername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80192%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ESie%20k%C3%B6nnen%20eine%20For()-Schleife%20verwenden%20oder%20etwas%20wie%20das%20Folgende%20tun%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%3EBetreff%3A%20Computername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80117%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EEs%20funktioniert.%20Aber%20was%20ist%2C%20wenn%20ich%2010%20Zeilen%20habe%20und%20in%20allen%20Zeilen%20unname%20haben%20m%C3%B6chte%3F%3C%2FP%3E%3CP%3EBenutze%20ich%20eine%20for-Schleife%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%3EBetreff%3A%20Computername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80054%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ESie%20m%C3%BCssen%20JMP%20mitteilen%2C%20in%20welcher%20Zeile%20der%20Datentabelle%20f%C3%BCr%20die%20Spalte%20%E2%80%9EBenutzer%E2%80%9C%20Sie%20den%20Wert%20speichern%20m%C3%B6chten.%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%3EDas%20Obige%20w%C3%BCrde%20den%20Wert%20von%20%E2%80%9Euname%E2%80%9C%20in%20Zeile%201%20f%C3%BCr%20die%20Spalte%20%E2%80%9Euser%E2%80%9C%20speichern.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-80045%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Computername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80045%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EIch%20muss%20den%20Benutzernamen%20des%20Computers%20abrufen%20und%20ihn%20in%20einer%20Spalte%20einer%20Datentabelle%20speichern.%20Ich%20verwende%20das%20folgende%20Skript%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Euname%20%3D%20Umgebungsvariable%20abrufen(%20%22COMPUTERNAME%22%20)%3B%3CBR%20%2F%3E%20dt%3Auser%20%3D%20uname%3B%3C%2FP%3E%3CP%3EDabei%20ist%20dt%20die%20Datentabelle%20und%20user%20der%20Name%20der%20Spalte.%3C%2FP%3E%3CP%3EAber%20ich%20erhalte%20die%20folgende%20Fehlermeldung%3A%3C%2FP%3E%3CP%3E%E2%80%9EDer%20Wert%20f%C3%BCr%20die%20Spalte%20%E2%80%9ABenutzer%E2%80%98%20kann%20nicht%20festgelegt%20werden%2C%20da%20die%20Zeilennummer%20(-1)%20ung%C3%BCltig%20ist.%E2%80%9C%3C%2FP%3E%3CP%3EKann%20mir%20bitte%20jemand%20sagen%2C%20was%20hier%20falsch%20ist%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%3EBetreff%3A%20Computername%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%3EDanke%2C%20die%20Syntax%20in%20JMP12%20ist%20eigentlich%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EGet%20Environment%20Variable(%22Computername%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%3EBetreff%3A%20Computername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3473%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EIch%20brauche%20etwas%2C%20das%20nicht%20durch%20etwas%20so%20Einfaches%20wie%20das%20Setzen%20der%20Umgebungsvariablen%20gehackt%20werden%20kann.Danke%20JohnP%20f%C3%BCr%20beide%20L%C3%B6sungen!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3472%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Computername%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%20unterst%C3%BCtzt%20diese%20Abfrage%20direkt%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EUmgebungsvariable%20(%E2%80%9EComputername%E2%80%9C)%20abrufen%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAm%20besten%2C%3C%2FP%3E%3CP%3E-Matt%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3471%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Computername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3471%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EIm%20urspr%C3%BCnglichen%20Beitrag%20wurde%20auch%20nach%20dem%20Computernamen%20gefragt.%20Um%20den%20Computernamen%20zu%20erhalten%2C%20verwenden%20Sie%20Kernel32.dll%20und%20den%20Methodennamen%20GetComputerNameA().%20Es%20wird%20also%20so%20aussehen%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%3D%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20DLL%20laden%3C%2FSPAN%3E%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%E2%80%9EKernel32.dll%E2%80%9C%3C%2FSPAN%3E%20)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20DeclareFunction(%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%E2%80%9EGetComputerNameA%E2%80%9C%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EKonvention(%20STDCALL%20)%2C%3C%2FP%3E%3CP%3EAlias%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%E2%80%9EGetComputerName%E2%80%9C%3C%2FSPAN%3E%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(AnsiString%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22Computername%22%3C%2FSPAN%3E%20%2C%20Ausgang%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(%20UInt64%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22L%C3%A4nge%22%3C%2FSPAN%3E%20%2C%20aktualisieren%20)%2C%3C%2FP%3E%3CP%3EGibt%20zur%C3%BCck%20(UInt32)%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3EName%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%20L%C3%A4nge%3C%2FSPAN%3E%20(Name)%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%3Ezeigen%3C%2FSPAN%3E%20(Name)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20UnloadDLL()%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EJohnP%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3470%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Computername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3470%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJohnP%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EVielen%20Dank!Genau%20das%20suche%20ich.Ich%20kann%20dies%20nicht%20als%20die%20richtige%20Antwort%20markieren%2C%20da%20ich%20diesen%20Thread%20nicht%20gestartet%20habe.%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%3EBetreff%3A%20Computername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3469%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHier%20ist%20eine%20JSL%2C%20die%20ich%20geschrieben%20habe%2C%20um%20den%20Benutzernamen%20vom%20System%20abzurufen.%20Dies%20funktionierte%20in%20JMP%2010%20unter%20Windows%207.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%3D%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20DLL%20laden%3C%2FSPAN%3E%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%E2%80%9Empr.dll%E2%80%9C%3C%2FSPAN%3E%20)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20DeclareFunction(%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%E2%80%9EWNetGetUserA%E2%80%9C%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EKonvention(%20STDCALL%20)%2C%3C%2FP%3E%3CP%3EAlias%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%E2%80%9EGetUserName%E2%80%9C%3C%2FSPAN%3E%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(%20UInt8%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22Format%22%3C%2FSPAN%3E%20%2C%20Eingabe%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(AnsiString%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22Nutzername%22%3C%2FSPAN%3E%20%2C%20Ausgang%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(%20UInt64%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22L%C3%A4nge%22%3C%2FSPAN%3E%20%2C%20aktualisieren%20)%2C%3C%2FP%3E%3CP%3EGibt%20zur%C3%BCck%20(UInt32)%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3EBenutzername%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%20L%C3%A4nge%3C%2FSPAN%3E%20(Nutzername)%3B%3C%2FP%3E%3CP%3Eresult%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%20Benutzername%2C%20unlen)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Ezeigen%3C%2FSPAN%3E%20(Nutzername)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20UnloadDLL()%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EZuerst%20m%C3%BCssen%20Sie%20die%20System-DLL%20laden.%20Mit%20Advapi32.dll%20hatte%20ich%20kein%20Gl%C3%BCck.%20Aber%20ich%20habe%20mit%20mpr.dll%20gefunden%2C%20was%20ich%20brauchte.%20Beachten%20Sie%2C%20dass%20ich%20keinen%20Pfad%20zur%20DLL%20angeben%20musste%2C%20da%20sie%20sich%20auf%20meinem%20Systempfad%20befand.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%3D%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20DLL%20laden%3C%2FSPAN%3E%20(%22mpr.dll%22)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAls%20n%C3%A4chstes%20m%C3%BCssen%20Sie%20jede%20Methode%20deklarieren%2C%20die%20Sie%20in%20der%20DLL%20aufrufen%20m%C3%B6chten.%20Die%20Methode%2C%20die%20ich%20verwenden%20m%C3%B6chte%2C%20hei%C3%9Ft%20eigentlich%20WNetGetUserA()%2C%20aber%20durch%20die%20Definition%20eines%20Alias%20kann%20ich%20sie%20einfach%20mit%20GetUserName()%20aufrufen.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20DeclareFunction(%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%E2%80%9EWNetGetUserA%E2%80%9C%3C%2FSPAN%3E%20%2C%3C%2FP%3E%3CP%3EKonvention(%20STDCALL%20)%2C%3C%2FP%3E%3CP%3EAlias%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%E2%80%9EGetUserName%E2%80%9C%3C%2FSPAN%3E%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(%20UInt8%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22Format%22%3C%2FSPAN%3E%20%2C%20Eingabe%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(AnsiString%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22Nutzername%22%3C%2FSPAN%3E%20%2C%20Ausgang%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E%20(%20UInt64%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22L%C3%A4nge%22%3C%2FSPAN%3E%20%2C%20aktualisieren%20)%2C%3C%2FP%3E%3CP%3EGibt%20zur%C3%BCck%20(UInt32)%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EJetzt%20m%C3%B6chte%20ich%20die%20Variablen%20definieren%2C%20die%20ich%20als%20Argumente%20%C3%BCbergeben%20werde.%20Ich%20erstelle%20einen%20Benutzernamen%20und%20initialisiere%20ihn%20mit%20Leerzeichen.%20Dann%20verwende%20ich%20die%20Funktion%20length()%20in%20JMP%2C%20um%20die%20aktuelle%20L%C3%A4nge%20des%20Puffers%20abzurufen%2C%20den%20ich%20gerade%20erstellt%20habe.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EBenutzername%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%20L%C3%A4nge%3C%2FSPAN%3E%20(Nutzername)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EJetzt%20kann%20ich%20die%20Funktion%20aufrufen.%20Beachten%20Sie%2C%20dass%20das%20erste%20Argument%20nur%20eine%20Eingabe%20ist%2C%20daher%20verwende%20ich%20einfach%20eine%20Konstante%2C%20anstatt%20eine%20Variable%20zu%20definieren.%20Dann%20zeigt%20der%20Befehl%20show()%20meinen%20Benutzernamen%20nach%20dem%20Anruf%20an.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Eresult%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%20Benutzername%2C%20unlen)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Ezeigen%3C%2FSPAN%3E%20(Nutzername)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EEndlich%20bin%20ich%20fertig%20und%20r%C3%A4ume%20auf.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20UnloadDLL()%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIch%20hoffe%2C%20das%20funktioniert%20f%C3%BCr%20Sie.%20Wenn%20Sie%20einen%20besseren%20Weg%20finden%2C%20lassen%20Sie%20es%20uns%20bitte%20wissen.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EDie%20Verwendung%20von%20loadDLL%20funktioniert%20%C3%BCbrigens%20nur%20unter%20Windows.%20Es%20wird%20auf%20dem%20Mac%20nicht%20unterst%C3%BCtzt.%20Aus%20diesem%20Grund%20pr%C3%BCfe%20ich%20oben%20in%20meinem%20Skript.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3ENamen%20standardm%C3%A4%C3%9Fig%20hier%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%3EWenn%3C%2FSPAN%3E%20(%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3E%20Gastgeber%20ist%3C%2FSPAN%3E%20(%20Mac%20)%2C%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EDrucken%3C%2FSPAN%3E%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%E2%80%9ELeider%20wird%20dieses%20Skript%20auf%20dem%20Mac%20nicht%20unterst%C3%BCtzt.%E2%80%9C%3C%2FSPAN%3E%20)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EStoppen%3C%2FSPAN%3E%20()%3B%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EGenie%C3%9Fen%2C%3C%2FP%3E%3CP%3EJohnP%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3468%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Computername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3468%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EKann%20mir%20jemand%20bei%20der%20Syntax%20zum%20Aufruf%20einer%20DLL%20helfen%3FIch%20m%C3%B6chte%20den%20Benutzernamen%20des%20Benutzers%20mithilfe%20der%20GetUserName-Funktion%20der%20Windows-API%20abrufen.Ich%20m%C3%B6chte%20die%20Umgebungsvariable%20%E2%80%9EBenutzername%E2%80%9C%20nicht%20nachschlagen%2C%20da%20diese%20gef%C3%A4lscht%20werden%20kann.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAdvapi32.dll%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EBOOL%20WINAPI%20GetUserName(%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%3EDanke!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3467%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Computername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3467%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EHallo%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%20Unter%20Windows%20XP%20und%20JMP%208%20kann%20man%20Windoz-Variablen%20%C3%BCber%20den%20LoadDLL-Befehl%20abrufen%20%E2%80%93%20(auch%20mit%20JMP%209%2C%20wenn%20man%20alle%20ENV-Variablen%20abrufen%20m%C3%B6chte).%20%3CBR%20%2F%3E%3CBR%20%2F%3EDas%20folgende%20Beispiel%20verwendet%20die%20Windows-Funktion%20%E2%80%9EGetEnvironmentStrings%E2%80%9C%2C%20um%20alle%20globalen%20Umgebungsvariablen%20(einschlie%C3%9Flich%20COMPUTERNAME)%20abzurufen%20und%20sie%20dann%20zum%20Spa%C3%9F%20in%20eine%20Datentabelle%20und%20ein%20Array%20zu%20laden.%3CBR%20%2F%3E%3CBR%20%2F%3E%20sehen%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%20Mit%20freundlichen%20Gr%C3%BC%C3%9Fen%2C%3CBR%20%2F%3E%20-Matt%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%3EBetreff%3A%20Computername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3466%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EHi%2C%3CBR%20%2F%3E%3CBR%20%2F%3E%20Ich%20verwende%20JMP%208.%20Gibt%20es%20dort%20eine%20%C3%A4hnliche%20Funktion%2C%20die%20den%20Computernamen%20abruft%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%20Panzer%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3465%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Computername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3465%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EHallo%20Pneil%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%20Unter%20Windows%20f%C3%BChren%20Sie%20im%20Startmen%C3%BC%20%E2%80%9EAusf%C3%BChren%E2%80%9C%20aus%2C%20%E2%80%9Ecmd%E2%80%9C%20%C3%B6ffnet%20ein%20DOS-Fenster.%20Geben%20Sie%20an%20der%20Eingabeaufforderung%20%E2%80%9Eset%E2%80%9C%20ein%2C%20um%20die%20Liste%20der%20aktiven%20Umgebungsvariablen%20anzuzeigen.%3CBR%20%2F%3E%3CBR%20%2F%3E%20Klicken%20Sie%20au%C3%9Ferdem%20mit%20der%20rechten%20Maustaste%20auf%20das%20Symbol%20%E2%80%9EMein%20Computer%E2%80%9C%20auf%20dem%20Desktop%20und%20w%C3%A4hlen%20Sie%20unten%20die%20Schaltfl%C3%A4che%20%E2%80%9EUmgebungsvariablen%E2%80%9C%20auf%20der%20Registerkarte%20%E2%80%9EErweitert%E2%80%9C%20aus.%3CBR%20%2F%3E%3CBR%20%2F%3E%20JMP%209%20enth%C3%A4lt%20die%20praktische%20Funktion%2C%20um%20diese%20aus%20der%20Umgebung%20abzurufen%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%20cname%20%3D%20Umgebungsvariable%20abrufen(%20%22COMPUTERNAME%22%20)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%20und%20man%20kann%20basierend%20auf%20dem%20zur%C3%BCckgegebenen%20Wert%20von%20dort%20aus%20entsprechend%20verzweigen.%3CBR%20%2F%3E%3CBR%20%2F%3E%20Mit%20freundlichen%20Gr%C3%BC%C3%9Fen%2C%3CBR%20%2F%3E%20-Matt%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-753036%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EBetreff%3A%20Computername%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-753036%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EBei%20mir%20hat%20es%20funktioniert%2C%20den%20aktuellen%20Benutzernamen%20unter%20Windows%20abzurufen%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)