CreateProcess doesn't pass command line arguments

前端 未结 8 2158
梦谈多话
梦谈多话 2020-12-01 10:20

Hello I have the following code but it isn\'t working as expected, can\'t figure out what the problem is.

Basically, I\'m executing a process (a .NET process) and pa

8条回答
  •  温柔的废话
    2020-12-01 11:17

    You are not allocating memory for your string.

    Instead of:

    LPTSTR cmdArgs = "name@example.com";
    

    try:

    TCHAR cmdArgs[] = "name@example.com";
    

    Edit: then call:

     CreateProcess("D:\\email\\smtp.exe", &cmdArgs[0], ...
    

    This will create a local array on the stack and then pass a pointer to that array.

提交回复
热议问题