实例:
(1)第一种方法CreateFile
char chBuffer[10] = "5469";
DWORD dwWriteSize = 0;
BOOL bRet = WriteFile(hDevice,chBuffer,4,&dwWriteSize,NULL);
if(bRet)
{
printf("write file success /n");
}
FlushFileBuffers(hDevice); //将缓冲区数据写入磁盘
LONG IDistance = 0;
DWORD dwPtr = SetFilePointer(hDevice,IDistance,NULL,FILE_BEGIN); //调整文件指针到文件开头
DWORD dwReadSize = 0;
bRet = ReadFile(hDevice,chBuffer,10,&dwReadSize,NULL);
if (bRet)
{
printf("chbuffer is %s /n",chBuffer);
}
CloseHandle(hDevice);
return ;
}
(2)第二种方法流文件操作FILE