gpt4 book ai didi

c++ - 通过 CreateProcessW 使用 "mkdir"创建的目录名称中的垃圾?

转载 作者:太空宇宙 更新时间:2023-11-04 05:43:52 25 4
gpt4 key购买 nike

运行以下代码后,一切都按照我的意愿进行,除了文件夹显示:test2﷽﷽ꮫꮫꮫꮫﻮﻮﻮ

这是怎么回事?

            std::string arrString[3] = {" /C mkdir C:\\Users\\Andrew\\Desktop\\test1"," /C mkdir C:\\Users\\Andrew\\Desktop\\test2"," /C mkdir C:\\Users\\Andrew\\Desktop\\test3"};
LPWSTR cmd =L"C:\\Windows\\System32\\cmd.exe";
int i;


for(i=0; i<3; i++)
{
STARTUPINFO info={sizeof(info)};
PROCESS_INFORMATION processInfo;
vector<wchar_t> cmdline(arrString[i].begin(), arrString[i].end());
CreateProcessW(cmd, &cmdline[0], NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo);
OutputDebugStringW(L"My output\nstring.");
}
}

最佳答案

cmdline 未正确终止 ASCIIZ。您可以检查这是否只是添加结尾 0 的原因(注意:未经测试和快速修改):

cmdline.push_back(0);

关于c++ - 通过 CreateProcessW 使用 "mkdir"创建的目录名称中的垃圾?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10955044/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com