Board index » delphi » Help on opening files and read 'em

Help on opening files and read 'em

Hmm What I want to do looks like this in Vis C++:
        // This will open an existing file for read/write

        HANDLE hReadFile;


        sa.lpSecurityDescriptor = NULL;
        sa.bInheritHandle = FALSE;
        sa.nLength = sizeof (sa);

        hReadFile = CreateFile ( szFileName, GENERIC_READ |
                                 GENERIC_WRITE, 0, &sa, OPEN_EXISTING,
                                 FILE_ATTRIBUTE_NORMAL, NULL);

        // this moves the file pointer 3750 bytes into the file from the
        // start of the file
        // *************************************************************

        DWORD dwPointer;

        dwPointer = SetFilePointer(hReadFile, 3750, NULL, FILE_BEGIN);

        // this 100 bytes from the file,
        // starting at the current file pointer position

        BOOL bRet;
        DWORD dwBytesRead;

        char szBuff[???];

        bRet = ReadFile (hReadFile, szBuff, 100, &dwBytesRead, FALSE);

And I wonder how you do it in Delphi32..


Re:Help on opening files and read 'em

Take a look at the example in the Help for BlockRead for one example of
opening/reading/writing/closing files.


Other Threads