I want to get the command line in a buffer, i.e. the command line without the program name. I know there are the GetCL and ArgCL functions in the masm lib, but that's not what I'm looking for. I just need the full command line without the program name. here's an example:
executed command:
myprogram.exe /option1 /option2 data.file blahblah
should translate to a buffer with: /option1 /option2 data.file blahblah
. What's a safe way of doing this (taking quotes etc into account)?
ThomasI'd do the eazy route and use the masm32 lib GetCL.
Now before you go off, listen: Use that to get the ZERO item (the program name), do a length on that, then use the lenght to index into the command line string, ie, add the lenght to the pointer to the command line.
Bingo, there's the string without the program name.
------------------------------------
"Oh my god! Space Aliens! Don’t eat me, I have a wife and kids! Eat them!"
Thomas,
The following code is an alternative way of getting a command
line without the file name at the front. "exist" is a library
function to test for a file's existence.
invoke PathGetArgs,CommandLine
mov lpArg, eax
mov esi, eax
lodsb
cmp al, 0
je noArgs ; jump if no arg
cmp al, 34
jne @F ; jump if no quote
invoke PathUnquoteSpaces,lpArg
mov lpArg, eax
@@:
invoke exist,lpArg
.if eax == 1
; code here to handle command line if it exists
.else
szText cantfind,"Sorry, cannot find that file."
invoke MessageBox,hWnd,lpArg,ADDR cantfind,MB_OK
.endif
noArgs:
Regards,
hutch@pbq.com.au