Reputation: 95
LPCTSTR applicationName = NUL // NULL => module name from command line
string argument1 = "something";
string argument2 = "anotherthing";
LPTSTR commandLine = "childpath\\child.exe";
success = CreateProcess(
applicationName,
commandLine,
processSecurityAttrs,etc...)
What I am trying to do here is trying to pass parent's command line args to child. But it is LPTSTR
, I do not know how to combine string
and LPTSTR
type and pass it to the child. It gives me type def. error. I use Visual Studio 2013 and C++.
Upvotes: 2
Views: 1379
Reputation: 23324
According to the documentation:
The Unicode version of this function, CreateProcessW, can modify the contents of this string. Therefore, this parameter cannot be a pointer to read-only memory (such as a const variable or a literal string). If this parameter is a constant string, the function may cause an access violation.
Example from the docs:
LPTSTR szCmdline[] = _tcsdup(TEXT("\"C:\\Program Files\\MyApp\" -L -S"));
CreateProcess(NULL, szCmdline, /* ... */);
Upvotes: 3