By using expertatexcel.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes

Become an Σxpert at Σxcel.com

 


GetCommandLine() - udf


Private Declare Function GetCommandLine Lib "kernel32" Alias _
   "GetCommandLineA" () As Long
Private Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" _
    (ByVal lpString1 As String, ByVal lpString2 As Long) As Long

Private Function CommandLine() As String
    Dim lpStr As Long, i As Long
    Dim buffer As String

    lpStr = GetCommandLine()
    buffer = Space$(512)
    lstrcpy buffer, lpStr
    buffer = Left$(buffer, InStr(buffer & vbNullChar, vbNullChar) - 1)
    CommandLine = buffer
End Function