WINBASEAPI
BOOL
WINAPI
ReadFile(
__in HANDLE hFile,
__out_bcount_part(nNumberOfBytesToRead, *lpNumberOfBytesRead) LPVOID lpBuffer,
__in DWORD nNumberOfBytesToRead,
__out_opt LPDWORD lpNumberOfBytesRead,
__inout_opt LPOVERLAPPED lpOverlapped
);
hFile是文件句柄。
lpBuffer是读写数据缓冲区。
nNumberOfBytesToRead是多少数据要读取。
nNumberOfBytesToRead是已经读取多少数据。
lpOverlapped是异步读写的结构。
例子
b_result = ReadFile(h_raw_h264_file, buffer_read.m_pBuffer, buffer_read.m_nBufferSize,
(DWORD*)&buffer_read.m_nDataSize, NULL);
还有是CreateFile 可以创建一个新文件 可以打开已经存在的文件
WINBASEAPI
BOOL
WINAPI
WriteFile(
__in HANDLE hFile,
__in_bcount(nNumberOfBytesToWrite) LPCVOID lpBuffer,
__in DWORD nNumberOfBytesToWrite,
__out_opt LPDWORD lpNumberOfBytesWritten,
__inout_opt LPOVERLAPPED lpOverlapped
);
hFile是文件句柄。
lpBuffer是读写数据缓冲区。
nNumberOfBytesToWrite是多少数据要写入。
lpNumberOfBytesWritten是已经写入多少数据。
h_ts_file = CreateFile (_T("c://test12.ts"), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, // normal file NULL); if (h_ts_file == INVALID_HANDLE_VALUE) { iError = GetLastError(); printf("Could not open file (error %d)/n", iError); return iError; } h_raw_h264_file = CreateFile (_T("C://test11.264"), GENERIC_READ, 0, NULL, OPEN_EXISTING, // overwrite existing FILE_ATTRIBUTE_NORMAL, // normal file NULL);