Article View: be.comp.programming
Article #5755Re: CreateFile
From: 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
Technical Details
Message-ID:
<V0saa.5686$oe.4577@amstwist00>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!upp1.onvoy!onvoy.com!priapus.visi.com!news-out.visi.com!petbe.visi.com!easynet-quince!easynet.net!feed1.news.be.easynet.net!skynet.be!skynet.be!213.51.129.3.MISMATCH!newshub1.home.nl!home.nl!amsnews01.chello.com!amstwist00.POSTED!not-for-mailReferences:
<TSraa.2409$Vq.380@afrodite.telenet-ops.be>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 107324,d7051ebf7a1600bb X-Google-Attributes: gid107324,public X-Google-Thread: fcea4,d7051ebf7a1600bb X-Google-Attributes: gidfcea4,public X-Google-ArrivalTime: 2003-03-08 12:04:10 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!upp1.onvoy!onvoy.com!priapus.visi.com!news-out.visi.com!petbe.visi.com!easynet-quince!easynet.net!feed1.news.be.easynet.net!skynet.be!skynet.be!213.51.129.3.MISMATCH!newshub1.home.nl!home.nl!amsnews01.chello.com!amstwist00.POSTED!not-for-mail From: "KLinZ" <klinz@NOSPAMzenobitsSPAMNO.com> Newsgroups: be.comp.programming,nl.comp.programmeren References: <TSraa.2409$Vq.380@afrodite.telenet-ops.be> Subject: Re: CreateFile Lines: 50 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: <V0saa.5686$oe.4577@amstwist00> Date: Sat, 8 Mar 2003 21:01:46 +0100 NNTP-Posting-Host: 212.187.71.152 X-Complaints-To: abuse@chello.nl X-Trace: amstwist00 1047153845 212.187.71.152 (Sat, 08 Mar 2003 21:04:05 MET) NNTP-Posting-Date: Sat, 08 Mar 2003 21:04:05 MET