[代码] windows磁盘根目录判断会为隐藏属性

判断C盘根目录是否为隐藏目录代码

#include <stdio.h>

#include <windows.h>


int is_hidden_file(const char *filename) {


    DWORD attributes = GetFileAttributesA(filename);


    if (attributes == INVALID_FILE_ATTRIBUTES) {


        return 0; // File does not exist


    }


    return (attributes & FILE_ATTRIBUTE_HIDDEN) != 0;


}


int main() {


    const char *filename = "C:";


    if (is_hidden_file(filename)) {


        printf("The file %s is a hidden file.n", filename);


    }
    else {


        printf("The file %s is not a hidden file.n", filename);


    }


    return 0;


}

结果会发现 C盘具有隐藏属性

点赞

本文标签: C++

版权声明:本博客所有文章除特别声明外,本文皆为《shiver blog》原创,转载请保留文章出处。

本文链接:[代码] windows磁盘根目录判断会为隐藏属性 - https://www.binary-monster.top/article/65

1

发表评论

电子邮件地址不会被公开。 必填项已用*标注