Like when i start a exe "filename.exe -switch1 -switch2 etc"?
Thanks.
Posted on 2003-05-17 11:15:12 by Ghirai
You can easily get the command line using:
      invoke GetCommandLine      ; returns a pointer to the command line in eax

mov CommandLine, eax


GetCommandLine API:
The GetCommandLine function returns a pointer to the command-line string for the current process.

LPTSTR GetCommandLine(VOID)


Parameters

This function has no parameters.

Return Values

The return value is a pointer to the command-line string for the current process.

Remarks

Non-Unicode console processes written in C can use the argc and argv arguments to access the command-line arguments. The parameters of the command-line string, excluding the program name, are also available to such non-Unicode applications as a parameter of the WinMain function. The reason for the Unicode exclusion from these options is that WinMain, argc, and argv use the LPSTR data type for parameters, not the LPTSTR datatype.
--------------
And from your WinMain:
WinMain proc hInst     :DWORD,

hPrevInst :DWORD,
[COLOR=blue]CmdLine :DWORD[/COLOR] ,
CmdShow :DWORD
Posted on 2003-05-17 11:23:10 by Guerrilla
If you do get command-line, you still need to slice it into parts:
.data

argc dd ?
argv dd 16 dup (?)
.code
ProcessCmdLine proc
push edi
push esi
push ebx
call GetCommandLine
mov esi, eax
mov edi, OFFSET argv
xor ecx, ecx
xor ebx, ebx
xor edx, edx
@@cmss: mov eax, esi
mov dl, 20h
cmp byte ptr [esi], 22h
sete cl
lea edx, [edx+ecx*2]
add eax, ecx
stosd
@@cm00: inc esi
cmp byte ptr [esi], 0
je @@cm01
cmp byte ptr [esi], dl
jne @@cm00
mov byte ptr [esi], 0
add esi, ecx
inc esi
cmp byte ptr [esi], 0
je @@cm01
inc [argc]
jmp @@cmss
@@cm01: pop ebx
pop esi
pop edi
inc [argc]
ret
ProcessCmdLine endp


would point to first parameter (executable name), to second parameter (-switch1), etc. C-style.
Posted on 2003-05-17 12:30:03 by comrade
Afternoon, Ghirai.

Also remember that, if you drag'n'drop a file onto an exe, you won't get the correct commandline supplied.

To make sure the commandline is supplied, drag'n'drop a file onto a ShortCut of your exe.

Cheers,
Scronty
Posted on 2003-05-17 23:06:53 by Scronty
Thanks a lot guys for the quick answer.
Posted on 2003-05-18 04:09:47 by Ghirai
Posted on 2003-05-18 04:37:52 by Vortex
Cool, thanks.
Posted on 2003-05-18 09:18:14 by Ghirai