1、CreateFile 是一个多功能的函数,可打开或创建以下对象,并返回可访问的句柄:控制台,通信资源,目录(只读打开),磁盘驱动器,文件,邮槽,管道。
2、例程:
#include int main(){ HANDLE hf = CreateFile(TEXT("C:\\testa.bin"), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0); DWORD written; WriteFile(hf, "\x0f\xff\xff\xff\xff\xff", 6, &written, 0); CloseHandle(hf); hf = CreateFile(TEXT("c:\\testb.bin"), GENERIC_WRITE, 0, 0, OPEN_ALWAYS, 0, 0); SetFilePointer(hf, 0, 0, FILE_END); WriteFile(hf, "\x0f\xff\xff\xff\xff\xff", 6, &written, 0); CloseHandle(hf); return 0;}
标签:CreateFile,函数