1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| ;@author : Progi1984
;@desc : Returns the current username
ProcedureDLL.s System_GetCurrentUser()
Protected sUsername.s
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux ;{
sUsername = GetEnvironmentVariable("USERNAME")
;}
CompilerCase #PB_OS_Windows ;{
Protected *MemUserName
Protected lMemSize.l
lMemSize = 1000
*MemUserName = AllocateMemory(lMemSize)
GetUserName_(*MemUserName, @lMemSize)
sUsername = PeekS(*MemUserName)
FreeMemory(*MemUserName)
;}
CompilerEndSelect
ProcedureReturn sUsername
EndProcedure
Debug System_GetCurrentUser()
|