[REBOL] Re: Getting username under windows
From: gregg:irwin::gmail at: 19-Mar-2007 10:22
Just getting back on the ML after being unsubscribed (it seems).
Wil; this work for you?
--Gregg
REBOL [
file: %WNetGetUser.r
Author: "Gregg Irwin"
EMail: greggirwin-acm.org
]
win-lib: load/library %mpr.dll
integer-struct: make struct! [
value [integer!]
] none
null-buff: func [
{Returns a null-filled string buffer of the specified length.}
len [integer!]
][
head insert/dup make string! len #"^-" len
]
WNetGetUser: make routine! compose/deep [
lpName [integer!] ; change to string if you need to use device name
lpUserName [string!]
lpLength [struct! [(first integer-struct)]]
return: [integer!]
] win-lib "WNetGetUserA"
rtn-name: null-buff 256
; If you wanted to find out exactly how much space you need first,
; you can all with a length of 0 and it will return the amount
; of space you need in the lpLength parameter.
len: make struct! integer-struct reduce [0]
print ["res: " res: WNetGetUser 0 rtn-name len]
print ["len: " len/value]
print ""
len: make struct! integer-struct reduce [length? rtn-name]
print ["res: " res: WNetGetUser 0 rtn-name len]
print ["name: " rtn-name]
print ""
free win-lib
halt