Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Getting username under windows

From: moliad:gmai:l at: 18-Mar-2007 17:38

here is full working code... I have this library in use in apps and its fully functional: the first line was to implement different implementations based on os, but I never got to it, by lack of need so far. hope this helps! -MAx ;----------------------- rebol [] isWin?: (system/version/4 = 3) ;- OS LIBS libsysinfo*: context [ libinfo: make library! switch system/version/4 [ ; other OSes will have to be filled in by other REBOLERS, as I have absolutely no idea. 3 [%Advapi32] ] username: make routine! [ "Get the current logon name of thread which launched REBOL" buffer [char*] count [string!] return: [integer!] ] libinfo "GetUserNameA" ] ;- ;- REBOL ACCESSORS ;- username username: func [/local buffer count][ buffer: head insert/dup copy "" #"^-" 100 ; this should cover any username! ;buffer: copy "..............................." count: third make struct! [val [integer!]] [100] unless isWin? [to-error "username only implemented for windows at this point"] either 0 < libsysinfo*/username buffer count [ return copy/part buffer (to-integer reverse count) - 1 ][ to-error "no username or invalid username" ] none ] probe username ask "..." ;-------------------------------- On 3/18/07, th72-dds.nl <th72-dds.nl> wrote: