任何类型的文件在C ++中都有自己的值吗? [英] Is any type file has own value in C++?

查看:97
本文介绍了任何类型的文件在C ++中都有自己的值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道文件夹的属性是C ++中的_A_SUBDIR。其他文件也有属性吗?例如,.txt或.exe ...

I know that the folder''s attribute is _A_SUBDIR in C++.Is Other file has attribute too? such as , .txt or .exe...

推荐答案





属性_A_SUBDIR来了来自C ++ CRT。如果您正在为Windows开发,最好使用Windows API函数和相应的常量 - 请参阅例如 MSDN文件属性常量



回到你的问题,我认为EXE文件或TXT文件没有这样的属性。但您可以通过后缀(.exe,.txt,...)来区分它们。对于其中一些文件(并非所有文件)都是特殊的验证规则,您必须检查内部的内容是否真的是文件类型的内容。例如。对EXE文件进行了这样的检查 - 当尝试执行EXE文件时,操作系统检查验证规则以查看它是否是有效的EXE文件 - 这些规则在 PE文件规范



希望这会有所帮助。



祝你好运,

JK
Hi,

tha attribute _A_SUBDIR comes from C++ CRT. If you are developing for Windows, you had better use Windows API functions and corresponding constants - see e.g. MSDN File Attributes Constants.

Back to your question, I think there is no such attribute for EXE file or TXT files. But you can distinguish them by their suffix (.exe, .txt, ...). For some of these files (not all) thare are special validation rules, that you have to check to see if the content inside is really that of the file type. E.g. There is such a check for EXE files - when trying to excecute an EXE file, OS check validation rules to see if it is a valid EXE file - these rules are described in the PE file Specification.

Hope this helps.

Best regards,
J.K.


这篇关于任何类型的文件在C ++中都有自己的值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆