#include "windows.bi" #include "vbcompat.bi" #ifndef False Const False=0, True=Not False #endif 'originally by Sebastian 'http://www.freebasic-portal.de/index.php?s=code&id=3 '+-------------------------------------------------------------------------------------+ '| Header: Evaluating parameters | '| DisplayCheck:|Il1 are Alt-0124, Big i, small L, One ߎę֚񱸩 | Const Author="lu.bas v1.0 (c)2012 by ytwinky, MD"' | '| (Shortcuts: none) | '| Purpose: Output the currently loggedon user with several options | '|Tested with the latest FB and the latest FBIde" | '+-------------------------------------------------------------------------------------+ 'ytwinky-version: Sebastian's programm as a string-function.. Function LoggedUser() As String Static As Integer BufferLen=255 'how much memory is needed? Dim UserPtr As ZString Ptr=Allocate(BufferLen) 'declare and reserve Function=*IIF(GetUserName(UserPtr, @BufferLen), UserPtr, @"*Error*")'IMPORTANT: Don't Return!! Deallocate UserPtr '..reserved memory has to be released.. End Function Var CrLf=!"\r\n", Msg="Current user: ", Halt=TRUE If __FB_ARGC__ >1 Then Halt=FALSE Select Case lcase(Command(1)) Case "/?", "/h", "-?", "-h", "--help" Msg=Author &!"\nSyntax:\nLU [/?]|[/1]|[/0]|[/d]\nWhere:\n" Msg &=!"/? is only ONE possibility to get this page(/?, /h, -?, -h, --help)\n" Msg &=!"/e output will be one single line(e.g. LOGs etc.)\n" Msg &=!"/u only the username will be output(e.g. for automations)\n" Msg &=!"/t adds Date and time[dd.mm.yyyy hh:mm:ss](sets /1)\n" Msg &=!"/j adds Date and time[yyyy-mm-dd hh:mm:ss](sets /1)\n" Print Msg &"Any other parameter(e.g. y) suppresses GetKey at end(not for this page).."; End 194 Case "/e": CrLf="" Case "/u": Msg="": CrLf="" Case "/t": Msg=Format(Now(), "dd.mm.yyyy hh:mm:ss ") &Msg: CrLf="" Case "/j": Msg=Format(Now(), "yyyy-mm-dd hh:mm:ss ") &Msg: CrLf="" End Select End If Print Msg &CrLf &LoggedUser(); If Halt Then GetKey End