The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on November 01, 2011, 07:12:57 PM

Title: Get Commandline args
Post by: ragdog on November 01, 2011, 07:12:57 PM
Hi

I need for my new Project a commandline switch function

Example:

Tool.exe /Read "c:\folder\test.txt"

With GetCommandLine ,PathGetArgs can i get the cmd switch and quoted path
to a Buffer >  /Read "c:\folder\test.txt" <
Must i parse the cmd switch?

Or gives a other Windows api as "CommandLineToArgvW" to get the cmd switches?

example
CommandLineToArgvA

Greets,
Title: Re: Get Commandline args
Post by: Vortex on November 01, 2011, 07:17:51 PM
Hi ragdog,

CommandLineToArgvW is an option. Also, you can have a look at the Command Line Procedures provided with the masm32 static library.
Title: Re: Get Commandline args
Post by: dedndave on November 02, 2011, 10:06:08 AM
open the help file
\masm32\help\masm32lib.chm

in the Contents...
Command Line

there are 4 functions
ArgCl
ArgClC
GetCl
getcl_ex

open the help file
\masm32\help\hlhelp.chm

i see 1 macro under Macro Catagories, String Macros
cmd$ - which will retrieve individual arguments
Title: Re: Get Commandline args
Post by: sinsi on November 02, 2011, 10:25:13 AM
http://www.masm32.com/board/index.php?topic=11477.msg86259#msg86259
Not for win9x though...
Title: Re: Get Commandline args
Post by: jj2007 on November 02, 2011, 10:43:07 PM
Quote from: Vortex on November 01, 2011, 07:17:51 PMCommandLineToArgvW is an option.

Apparently it's a bit messy, the top Google hits for CommandLineToArgvW are not that positive. I am using GetCommandLineW for the MB wCL$() macro, example here (http://www.masm32.com/board/index.php?topic=12460.msg148836#msg148836). However, if I read the initial post right, ragdog is not really interested in Unicode...