R17
First, you must know who is the current user in for that particular workstation. In other words, the user must logged into windows. Also the username for workstation must be the same with username on the network.
If not then you have to hardcode the username and network username, or you can figure out yourself
Here is the code if the user is logged, and the username on the net is the same.
* ----------------------
Declare Long WNetGetUser in MPR ;
String cUserName, String @cReturnName, Long @nLen
nLen = 80
cBuffer = replicate(chr(0), nLen)
nError = WNetGetUser(Null, @cBuffer, @nLen) && Get current user
If (nError == 0)
cUser = left(cBuffer, at(chr(0), cBuffer)-1)
cBuffer = replicate(chr(0), nLen)
** Get the network username for current user
nError = WNetGetUser(cUser, @cBuffer, @nLen)
If (nError == 0)
? 'Net username: ' + left(cBuffer, nLen-1)
else
? 'Error: ', nError
If (nError == 1245)
? 'User is not connected to network'
endif
endif
else
? 'Error: ', nError
** ? 'User is not logged on in this computer'
endif
* -------------------
Hope it helps
-- AirCon --