Xài Visual C++ 6, mục đích là tạo 1 file và ghi 4 byte "yeah" vào đó: Mã: HANDLE hFile; DWORD numByteWritten; char* buff = "Yeah"; hFile = CreateFile("D:\\a.txt", // file to create GENERIC_WRITE, // open for writing 0, // do not share NULL, // default security CREATE_ALWAYS, // overwrite existing FILE_ATTRIBUTE_NORMAL | // normal file FILE_FLAG_OVERLAPPED, // asynchronous I/O NULL); // no attr. template if (hFile == INVALID_HANDLE_VALUE) return; int r = WriteFile(hFile,buff,4,&numByteWritten,NULL); if(r == 0) DWORD e = GetLastError(); CloseHandle(hFile); Đơn giản vậy thui... kô hiểu tui làm sai chổ nào mà cái file tạo ra chẳng có dữ liệu. Giá trị r hàm WriteFile trả về = 0 và Error code = 87 (ERROR_INVALID_PARAMETER). Ai biết giúp giùm tui nhé, thx nhìu.