|
Получение всех параметров командной строки |
|
|
Простой пример, как можно получить все значения командной строки.
Вам понадобится элемент CommandButton. Private Declare Function GetCommandLine Lib "kernel32" Alias
"GetCommandLineA" () As String
Function ParamStr(index As Integer) As String
Dim str As String
Dim PStr() As String
Dim i As Integer
Dim c As Integer
Dim openQ As Boolean
str = GetCommandLine
c = 0
ReDim PStr(c)
For i = 1 To Len(str)
PStr(c) = PStr(c) + Mid(str, i, 1)
If Mid(str, i, 1) = Chr(34) And openQ = False Then openQ = True Else If Mid(str, i, 1) =
Chr(34) And openQ = True Then openQ = False
If Mid(str, i, 1) = " " And openQ = False Then
c = c + 1
ReDim Preserve PStr(c)
End If
Next i
If (index > c) Then ParamStr = "" Else ParamStr = deleteQ(PStr(index))
End Function
'эта функция удаляет кавычки из строки
Function deleteQ(str As String) As String
For i = 1 To Len(str)
If Mid(str, i, 1) <> Chr(34) Then deleteQ = deleteQ + Mid(str, i, 1)
Next i
End Function
Private Sub Command1_Click()
MsgBox ParamStr(1)
MsgBox ParamStr(2)
MsgBox ParamStr(3)
End Sub
|
|
|
|
|
|
|