创建文件
AnsiString FileName="C:\\aaa01.txt";
char TheText[MAX_PATH]="这是 CreateFile 函数测试文字内容";
HANDLE TheFile;
DWORD BytesWritten;
TheFile=CreateFile(FileName.c_str(),
GENERIC_WRITE,FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if(TheFile==INVALID_HANDLE_VALUE)
{
ShowMessage("无法建立新文件!");
return;
}
if(!WriteFile(TheFile,TheText,sizeof(TheText),&BytesWritten,NULL) ||
sizeof(TheText)!=BytesWritten)
{
ShowMessage("文件无法写入新资料!");
}
//
::CloseHandle(TheFile);