Thread View: be.comp.programming
3 messages
3 total messages
Started by Ivan Van den Bossche
Sat, 08 Mar 2003 19:53
CreateFile
Author: Ivan Van den Bossche
Date: Sat, 08 Mar 2003 19:53
Date: Sat, 08 Mar 2003 19:53
9 lines
1462 bytes
1462 bytes
Hi, Ik gebruik in de programmeertaal C de Windows functie CreateFile om een file te openen en op een bepaald punt moet ik de huidige positie opvragen in bytes ten opzichte van het begin van deze file (offset). Weet er iemand hoe ik die positie in bytes kan opvragen? Alvast bedankt. Ivan
Re: CreateFile
Author: KLinZ
Date: Sat, 08 Mar 2003 20:01
Date: Sat, 08 Mar 2003 20:01
49 lines
2840 bytes
2840 bytes
Ivan Van den Bossche wrote:
> Hi,
>
> Ik gebruik in de programmeertaal C de Windows functie CreateFile om
> een file te openen en op een bepaald punt moet ik de huidige positie
> opvragen in bytes ten opzichte van het begin van deze file (offset).
> Weet er iemand hoe ik die positie in bytes kan opvragen?
>
> Alvast bedankt.
> Ivan
Met SetFilePointer kun je zowel de file pointer zetten als uitlezen:
*Retrieving a File Pointer*
The SetFilePointer function can be used to query the current file pointer
position, by specifying a move method of FILE_CURRENT and a distance of
zero.
HANDLE hFile;
DWORD dwCurrentFilePosition;
dwCurrentFilePosition = SetFilePointer(
hFile, // must have GENERIC_READ and/or GENERIC_WRITE
0, // do not move pointer
NULL, // hFile is not large enough to need this pointer
FILE_CURRENT); // provides offset from current position
The following macro can be used to obtain the current file pointer position
for files smaller than 2 gigabytes in size:
#define GetFilePointer(hFile) SetFilePointer(hFile, 0, NULL, FILE_CURRENT)
To get the current file positions on larger files, use the following:
#define GetVLFilePointer(hFile, lpPositionHigh) \
(*lpPositionHigh = 0, \
SetFilePointer(hFile, 0, lpPositionHigh, FILE_CURRENT))
where lpPositionHigh is a value of type PLONG. The high order long word of
the current file position will be returned in lpPositionHigh.
--
www.zenobits.com
Re: CreateFile
Author: Pieter Philippaerts
Date: Sat, 08 Mar 2003 20:03
Date: Sat, 08 Mar 2003 20:03
18 lines
2173 bytes
2173 bytes
"Ivan Van den Bossche" <ivan.van.den.bossche@pandora.be> wrote in message news:TSraa.2409$Vq.380@afrodite.telenet-ops.be... > Weet er iemand hoe > ik die positie in bytes kan opvragen? Je kan dat doen via SetFilePointer(). Wat je doet is die methode aanroepen met dwMoveMethod = FILE_CURRENT, lDistanceToMove = 0 en lpDistanceToMoveHigh = 0 [je kan hier ook NULL specifieren, maar dan kan je nooit de positie opvragen van files > 4.2Gb]. Nadat je die methode hebt aangeroepen geeft die je de huidige positie terug: "If the SetFilePointer function succeeds and lpDistanceToMoveHigh is NULL, the return value is the low-order DWORD of the new file pointer. If lpDistanceToMoveHigh is not NULL, the function returns the low order DWORD of the new file pointer, and puts the high-order DWORD of the new file pointer into the LONG pointed to by that parameter." Mvg, Pieter Philippaerts
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads