// *** Create a test.txt file with some data. *** { const HANDLE hFile = ::CreateFileA( "c:\\temp\\test.txt", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); std::string X( "abcdefg" ); DWORD dwWritten; const BOOL rc1 = ::WriteFile( hFile, X.data(), X.size(), &dwWritten, NULL ); ::CloseHandle( hFile ); } // *** Write the date/time to the test.txt:ea.ini ADT. *** // Note: This works with QFile! // QFile B( "c:\\temp\\test.txt:ea.ini" ); // const bool bFileOpenB = B.open( QIODevice::WriteOnly | QIODevice::Text ); // qint64 u = B.write( X ); // B.close(); { const QDateTime qdt = QDateTime::currentDateTime(); QByteArray X = qPrintable( qdt.toString() ); const HANDLE hFile = ::CreateFileA( "c:\\temp\\test.txt:ea.ini", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); DWORD wdWritten; const BOOL rc1 = ::WriteFile( hFile, X.data(), X.size(), &wdWritten, NULL ); const BOOL rc2 = ::CloseHandle( hFile ); } // *** Read data from the test.txt:ea.ini ADT *** // Note: This doesn't work with QFile! // QFile C( "c:\\temp\\test.txt:ea.ini" ); // const bool bFileOpenC = C.open( QIODevice::ReadOnly | QIODevice::Text ); // const QByteArray Y = C.readAll(); { const HANDLE hFile = ::CreateFileA( "c:\\temp\\test.txt:ea.ini", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); DWORD dwFileSizeHigh; DWORD dwFileSizeLow = ::GetFileSize( hFile, &dwFileSizeHigh ); DWORD dwWritten; char* const pBuf = new char[dwFileSizeLow + 1]; const BOOL rc1 = ::ReadFile( hFile, pBuf, dwFileSizeLow, &dwWritten, NULL ); pBuf[dwFileSizeLow] = '\0'; ::CloseHandle( hFile ); }