我对这段代码的行为感到困惑。
const char* file_name = "/ /";
auto attributes = GetFileAttributes(TEXT(file_name)); // same result without TEXT macro
if (attributes == INVALID_FILE_ATTRIBUTES)
{
//error
}
else if (attributes == FILE_ATTRIBUTE_DIRECTORY)
{
//directory
}
Run Code Online (Sandbox Code Playgroud)
这是文件或目录的无效名称,因此我希望它返回 INVALID_FILE_ATTRIBUTES。用VS2015编译运行在win8上。也许这是因为前向字符?也许有一个 winAPI 函数来验证输入?
谢谢