Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Command Line Parameters on an EXE
#5
Function ParseCommandLine
Code:
Copy      Help
;/
function $cmdLine ARRAY(str)&a

;Parses command line.
;Uses the same rules as most programs. <link "http://www.google.com/search?q=site%3amicrosoft.com%20Parsing%20C%2b%2b%20Command-Line%20Arguments">Read more</link>.

;cmdLine - command line.
;;;Can be path followed by command line. Then a[0] will be the path.
;a - receives command line arguments.


a=0
if(empty(cmdLine)) ret
int i n
word** w=CommandLineToArgvW(@cmdLine &n)
for(i 0 n) a[].ansi(w[i])

LocalFree w

example
Macro Macro1465
Code:
Copy      Help
out

str cl="/A /B bbb /c ''ccc ccc'' ''\''ddd ddd\''''"
;str cl="''c:\xx xx\yyy.exe'' /A /B"
ARRAY(str) a
ParseCommandLine(cl a)

int i
for i 0 a.len
,out a[i]


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)