您的位置:首页 > 其它

windows开发各种细节.....

2010-11-09 20:29 232 查看
我发现windows自己的API一般不能做到与windows自己的历史兼容。很神奇...

下面几个函数都前后不兼容.

例如GetFileTime这个函数。本来是得到文件的读写时间。但是因为windows自己很有趣,自己的的读写时间其实并不是用户真正的读写时间。当然可能人家考虑了效率等其他的问题。下面一段是摘抄自MSDN中的介绍:

Not all file systems can record creation and last access times and not all file systems record them in the same manner. For example, on FAT, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution of 1 day (really, the access date). Therefore, the GetFileTime function may not return the same file time information set using SetFileTime. NTFS delays updates to the last access time for a file by up to one hour after the last access.

不是所有的文件系统都能记录创建时间和最后的访问时间。也不是所有的文件系统都以相同的方式记录他们。比如在FAT上,创建时间误差是10微秒,写时间的误差2秒,访问时间的误差是1天!(...我觉得hacker可以在这个一天上做些手脚..)因此,就是你使用SetFileTime这个函数,GetFileTime也不可能会返回相同的时间...NTFS会延迟一小时更新最后的访问时间...

真是无语呀..

FindNextFile这个函数有些小问题,就是不能以字母序返回文件...在FAT和在NTFS系统上的表现不一样...大概的原因在于那个文件描述表中存放顺序是不一样的.FAT是使用的时间顺序存放,而NTFS是使用的按字母序存放。这个FindNextFile根本没有做啥事情,直接读出来..这个API就是仅仅追求效率...顺便一提..它其实应该再开发一个API叫做FindSortedNextFile...这样更好些..不过我想它也不能做..解决途径..上层排个序先。

The order in which this function returns the file names is dependent on the
file system type. With the NTFS file system and CDFS file systems, the names are
returned in alphabetical order. With FAT file systems, the names are returned in
the order the files were written to the disk, which may or may not be in
alphabetical order.


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息