Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[18.191.216.163] |
|
Сообщ.
#1
,
|
|
|
Вам никогда не приходило в голову написать свой парсер командной строки?
Который бы разбирал что-то типа a b "x\"x" 555 Однако, в windows уже есть функция, которое все распарсит сама. Option Explicit Private Declare Function CommandLineToArgvW Lib "shell32.dll" (ByVal nInput As Long, ByRef retcount As Long) As Long Private Declare Function LocalFree Lib "kernel32" (ByVal hMem As Long) As Long Private Declare Function SysAllocString Lib "oleaut32" (ByVal nString As Long) As Long Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As Long, ByVal Source As Long, ByVal Length As Long) Public Function CommandLineToArgvVB(ByVal nInput As String) As String() Dim ret As Long, retcount As Long, rt() As String, I As Integer, lng As Long ret = CommandLineToArgvW(StrPtr(nInput), retcount) If retcount > 0 Then ReDim rt(retcount - 1) For I = 0 To UBound(rt) CopyMemory VarPtr(lng), ret + I * 4, 4 CopyMemory VarPtr(rt(I)), VarPtr(SysAllocString(lng)), 4 Next CommandLineToArgvVB = rt End If If ret <> 0 Then LocalFree ret End Function Использование: Private Sub Form_Load() Dim ret() As String, I As Long ret = CommandLineToArgvVB("a b ""xx yy"" \""abc") MsgBox Join(ret, vbCrLf) End End Sub |