I am having a bit of problem using CreateProcess()
.
In this example, CreateProcess()
works perfectly fine:
bSuccess = CreateProcess(
TEXT("os-util.exe"),
TEXT("os-util.exe 0x273e:0x0007:0x0100 --get-channel"), NULL, NULL, TRUE,
0,
NULL, szFileName, &si, &pi);
The problem is that I want to modify the command line that I pass. I tried a few solutions, but they didn't give me any good results. For example:
LPWSTR cmdArgslistSetChannel[] = { TEXT("os-util.exe"), TEXT("0x273e:0x0007:0x0100"), TEXT("--set-channel"), TEXT("11") };
bSuccess = CreateProcess(
TEXT("os-util.exe"),
cmdArgslistSetChannel, NULL, NULL, TRUE,
0,
NULL, szFileName, &si, &pi);
how can I change just part of the
TEXT("")
?how can I make the command line from more than one
TEXT("")
?
If none of these options are available, what can be done? I want a UI button push to call CreateProcess()
with different command line arguments.
Use
std::wstring
and string concatenations to build up your command line dynamically, eg:Alternatively, use
std::wostringstream
for the buildup, and then retrieve astd::wstring
from it:Either way, you can then replace any individual substring as needed.