Platform SDK: DLLs, Processes, and Threads

CommandLineToArgvW

The CommandLineToArgvW function parses a Unicode command-line string. It returns a pointer to a set of Unicode argument strings and a count of arguments, similar to the standard C run-time argv and argc values. The function provides a way to obtain a Unicode set of argv and argc values from a Unicode command-line string.

LPWSTR * CommandLineToArgvW(
  LPCWSTR lpCmdLine,  // pointer to a command-line string
  int *pNumArgs       // receives the argument count
);

Parameters

lpCmdLine
[in] Pointer to a null-terminated Unicode command-line string. An application will usually directly pass on the value returned by a call to the GetCommandLineW function.

If this parameter is the empty string, "", the function returns the path to the current executable file.

pNumArgs
[out] Pointer to an integer variable that receives the count of arguments parsed.

Return Values

If the function succeeds, the return value is a non-NULL pointer to the constructed argument list, which is an array of Unicode strings.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks

It is the caller's responsibility to free the memory used by the argument list when it is no longer needed. To free the memory, use a single call to the GlobalFree function.

Requirements

  Windows NT/2000: Requires Windows NT 3.5 or later.
  Windows 95/98: Unsupported.
  Header: Declared in Shellapi.h; include Windows.h.
  Library: Use Shell32.lib.
  Unicode: Implemented only as Unicode.

See Also

Processes and Threads Overview, Process and Thread Functions, GetCommandLine, GlobalFree