gpt4 book ai didi

winapi - CreateProcess 对没有扩展名的文件有奇怪的行为

转载 作者:行者123 更新时间:2023-12-02 03:46:41 25 4
gpt4 key购买 nike

我注意到了这种行为:

当前目录下有2个可执行文件,分别名为“somefile”和“somefile.abc”。

CreateProcessA(NULL, "somefile", ...) - 失败,错误代码为 2 (ERROR_FILE_NOT_FOUND)

CreateProcessA(NULL, "somefile.abc", ...) - 有效

CreateProcessA(NULL, ".\\somefile", ...) - 有效

CreateProcessA(NULL, ".\\somefile.abc", ...) - 有效

因此,当且仅当文件没有扩展名时,“.\”才是必需的。这种行为背后有逻辑吗?

最佳答案

来自MSDN :

If the file name does not contain an extension, .exe is appended. Therefore, if the file name extension is .com, this parameter must include the .com extension. If the file name ends in a period (.) with no extension, or if the file name contains a path, .exe is not appended.

我不知道记录的行为是否应该被称为“奇怪”。

关于winapi - CreateProcess 对没有扩展名的文件有奇怪的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43139364/

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