最好的3d电影下载网站:WIN32 API里的CreateFile函数如何使用绝对路径

来源:百度文库 编辑:中科新闻网 时间:2024/05/05 20:16:54
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
);
参数 lpFileName可以为相对路径如“aaa.txt”
但不能用绝对路径 如“c:\aaa.txt”怎么不办

HANDLE hfile = CreateFile(_T("G:\\测试\\myfile.txt"),GENERIC_WRITE|GENERIC_READ,0
,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
如果第一个参数为_T("G:\\myfile.txt")则失败,不能直接根目录。