Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4470493
  • 博文数量: 356
  • 博客积分: 10458
  • 博客等级: 上将
  • 技术积分: 4734
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-24 14:59
文章分类

全部博文(356)

文章存档

2020年(17)

2019年(9)

2018年(26)

2017年(5)

2016年(11)

2015年(20)

2014年(2)

2013年(17)

2012年(15)

2011年(4)

2010年(7)

2009年(14)

2008年(209)

分类: C/C++

2008-04-13 11:18:55

使用_access函数,函数原型为

int _access( const char *path, int mode );

使用CreateFile函数,函数原型为:                                            HANDLE CreateFile(
LPCTSTR lpFileName,          // pointer to name of the file
DWORD dwDesiredAccess,       // access (read-write) mode
DWORD dwShareMode,           // share mode
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
                               // pointer to security attributes
DWORD dwCreationDisposition, // how to create
DWORD dwFlagsAndAttributes, // file attributes
HANDLE hTemplateFile         // handle to file with attributes to
                               // copy
);

使用FindFirstFile函数,函数原型为:                                 HANDLE FindFirstFile(
LPCTSTR lpFileName, // pointer to name of file to search for
LPWIN32_FIND_DATA lpFindFileData
                       // pointer to returned information
);

使用GetFileAttributes函数,函数原型如下:                        DWORD GetFileAttributes(
LPCTSTR lpFileName   // pointer to the name of a file or directory
);
使用Shell Lightweight Utility APIs函数
PathFileExists()专门判断文件和目录时否存在的函数
文件名可读性比较强
还可以判断目录是否存在

Header: Declared in Shlwapi.h
Import Library: Shlwapi.lib

以上的各种方法供参考,函数具体用法需参见MSDN。

阅读(4567) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~