Write("文件名",结构体,sizeof(结构体));
BOOL Write(char* filePath,char *buffer,DWORD dwBytesToWrite)
{
HANDLE pFile;
char *tmpBuf;
DWORD dwBytesWrite;
pFile = CreateFile(filePath,GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS, //总创建文件
FILE_ATTRIBUTE_NORMAL,
NULL);
if ( pFile == INVALID_HANDLE_VALUE)
{
printf("create file error!\n");
CloseHandle(pFile);
return FALSE;
}
dwBytesToWrite = 32;
dwBytesWrite = 0;
tmpBuf = buffer;
WriteFile(pFile,tmpBuf,dwBytesToWrite,&dwBytesWrite,NULL);
CloseHandle(pFile);
return true;
}
取消
评论